Arduino Forum

Using Arduino => Microcontrollers => Topic started by: PaulRB on Sep 09, 2014, 11:11 pm

Title: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: PaulRB on Sep 09, 2014, 11:11 pm
UPDATED 28/04/2015:

A new forum has been set up to replace this thread:

http://www.stm32duino.com (http://www.stm32duino.com)

This thread will continue to be updated but only for posting any major announcements in the future. Please use the new forum to continue any current discussions, raise new issues or ask for advice.



UPDATED 28/12/2014:

As this thread is now over 50 pages long, a Wiki has been created to organise all the useful information from the thread:

https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)


ORIGINAL POST:

It sounds amazing value at first glance...

http://www.ebay.co.uk/itm/High-Quality-STM32F103C8T6-ARM-STM32-Development-Board-Module-For-Arduino-Tool-/251621420724?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item3a95ce2eb4

but how is it connected with Arduino (or claiming to be)?

Neither of the web addresses seem to work either!
Title: Re: What's this I found on eBay?
Post by: Coding Badly on Sep 09, 2014, 11:30 pm

It's connected to the Arduino in the sense that it is a competitor.

This should get you information about similar boards...
https://www.google.com/?gws_rd=ssl#q=STMicroelectronics+arduino
Title: Re: What's this I found on eBay?
Post by: mart256 on Sep 09, 2014, 11:32 pm
These Hong Kong vendors put the word "Arduino" on any electronic device just to sell more stuff.

This is a microcontroller, brand is STM and it's core is ARM 32 Cortex-M3.
It's kinda the little brother of Arduino DUE, and it's much cheaper.
Includes debug on board (USB).
Title: Re: What's this I found on eBay?
Post by: mcnobby on Sep 10, 2014, 05:02 pm
This one is even cheaper -> http://www.ebay.co.uk/itm/ARM-Cortex-M3-Leaflabs-Leaf-Maple-Mini-Module-STM32-for-Arduino-/111450858151?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item19f2fd22a7 (http://www.ebay.co.uk/itm/ARM-Cortex-M3-Leaflabs-Leaf-Maple-Mini-Module-STM32-for-Arduino-/111450858151?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item19f2fd22a7)

Does this actually connect to the arduino IDE ?
anyone know or have any information ?

Regards

EDIT : STM32 Maple / Arduino WIKI :
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
Title: Re: What's this I found on eBay?
Post by: mart256 on Sep 10, 2014, 05:32 pm
If you read the description it says it has its own ide called maple, they claim it is code compatible with Arduino. This means you can grab the blink example and paste it on maple ide, and it will compile.
Title: Re: What's this I found on eBay?
Post by: PaulRB on Sep 10, 2014, 09:36 pm

This one is even cheaper


And the Maple IDE and implementation of Wiring looks very Arduino-like.

Good spot mcnobby!
Title: Re: What's this I found on eBay?
Post by: luisilva on Sep 10, 2014, 10:15 pm
I believe that can be difficult using some shield because there will not be some compatible libraries.

Title: Re: What's this I found on eBay?
Post by: mart256 on Sep 10, 2014, 10:21 pm

I believe that can be difficult using some shield because there will not be some compatible libraries.




It depends on how big the community is.
The launchpad community seems to be growing and they have translated many arduino libraries, same with teensy and pinguino.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Sep 11, 2014, 08:30 am
I just bought one of those mini maple leafs, at only a few quid it is worth the risk just to find out how it flies.

I already have a Due, and I love its speed, just dont like the bulk, so for me I dont care about shields

Once it arrives and I have had a play I will be back to let you all know

:)
Title: Re: What's this I found on eBay?
Post by: PaulRB on Sep 11, 2014, 05:04 pm

I just bought one of those mini maple leafs, at only a few quid it is worth the risk just to find out how it flies.


Me too (the Maple clone, not the original item I posted)

The Maple documentation & IDE seems reasonably good. Lets hope these clones are not significantly different in any important respect. The only differences the vendor mentions is related to power supply and board layers. This may mean we won't get the 11~12 bits accuracy of the original Maple on the analog inputs.

Shame the Maple forum is a graveyard compared to Arduino forum! Sounds like LeafLabs may be abandoning support, or at least future development for the Mini.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Sep 11, 2014, 05:15 pm
|t would be nice if Arduino could pick up the old Maple Leaf support and bundle it in with the arduino IDE
Title: Re: What's this I found on eBay?
Post by: PaulRB on Sep 11, 2014, 06:33 pm

|t would be nice if Arduino could pick up the old Maple Leaf support and bundle it in with the arduino IDE


They've had plenty of time to invent a Due-Mini, but seem to have decided to explore other avenues (Yun etc)
Title: Re: What's this I found on eBay?
Post by: Paul__B on Sep 11, 2014, 11:52 pm

I just bought one of those mini maple leafs, at only a few quid it is worth the risk just to find out how it flies.

And me too - marginally cheaper again on the Australian site.  The seller (I figure one seller frequently operates under a number of names; they come with the same postmark!) might wonder about/ be amused by the sudden "blip" in sales of one item.  :D

It's sort of a beefed-up Nano, as is Crossroads' device. Runs at 3.3V so you really, really don't want to stress the regulator.  And the clone is very much stripped-down from the original, missing the analog noise minimisation features.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Sep 12, 2014, 05:06 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


I just completed a 90-day play with the PSoC $4 32-bit ARM prototype boards running at 48MHz with 32K EEPROM and 4K SRAM.
http://www.cypress.com/?rID=92146 (http://www.cypress.com/?rID=92146)

My initial observations and my final feelings are posted here (also the projects are on this site):
http://www.hackster.io/rayburne/psoc-4-the-arduino-killer (http://www.hackster.io/rayburne/psoc-4-the-arduino-killer)

But in general, the ARM 32-bit is just another processor.  In most of the projects that I cloned from the Arduino world, the 8-bit Arduino worked equally as well as the 32-bit ARM.  The Cypress PSoC has some great hardware features such as OpAmps, Configurable digital blocks, and way cool PWM.  But, the downside is the community... small communities mean more work for me (you) as you must research, implement, write, lots of support software.

Personally, except for specific things such as FFT or native 32-bit algorithms, I think the Arduino 8-bit and Due 32-bit environments are more productive.  Although the GUI is a sad excuse when compared to what professional tools can provide.

In my case, it comes down to fun.  I learned a lots with the 32-bit ARM but I also used a lots of 4-letter words from my old Air Force days.

Here is the last sentence of my blog:
Quote
Hurry-up and wait in the Arduino translated to hurry-up and wait longer in the PSoC.
Ray
Title: Re: What's this I found on eBay?
Post by: PaulRB on Sep 13, 2014, 06:02 pm
Hi Ray,

You're absolutely right on 2 counts (at least):

1. The community is often the most important component for getting a project working! It was/is true of the PicAxe forum and its true here.

2. Simpler is often better for the hobbyist. That's why Arduino has been successful. When the hobbyist outgrows the 8-bit AVRs, the need is often simply for more speed, ram and/or flash.

Megas, Bobuinos and the like only really provide 2 of those 3. The 16 (or 20) MHz limit, combined with 8-bit architecture, can become the next bottleneck.

Having said that, and before anyone else comments, I expect 4 out of 5 Arduino users hit those limits because of inefficiencies in their own sketch. Learning to make better use of those limited resources is where they should probably focus, rather than immediately reaching for more powerful hardware, because that will only result in their sketch becoming even more inefficient!

You probably remember my fascination with Conway's Game of Life. I would still like to adapt my algorithm for a larger matrix. For that I would need more ram. Currently it maxes out the ram on a mega328 processing a 128x64 matrix. A Mega644/1284 would allow that, but to keep up the speed on that larger matrix, I would need more processing speed too. So that's one thing I would like to try out on this ARM-thing one day.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Sep 13, 2014, 06:14 pm
Hi Paul,
I have been using a 32mhz TTL clock generator on a atmega328 for some time now without any problems, I think the 20mhz limit maybe for using crystals, I used 20mhz xtal and it was fine, but a 24mhz xtal just didnt start, so I decided to try the ttl clocks

not noticeably hot by the way ;)
Title: Re: What's this I found on eBay?
Post by: PaulRB on Sep 13, 2014, 06:40 pm
Interesting, mcnobby!

But I was thinking of, for example, a 320x240 pixel lcd. That's 10 times as many cells in the Life matrix as 128x64, so would need 10 times the ram and 10 times the processing speed. The move from 8 to 32 bit architecture might get me a 4x speed improvement, so I would need another 3x clock speed improvement also (this is all back-of-a-fag-packet obviously). I would probably need 10x SPI speed also to update the display quickly enough.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Sep 13, 2014, 08:13 pm
crikey !!!

exponential-o-rama !!!
Title: Re: What's this I found on eBay?
Post by: smeezekitty on Sep 13, 2014, 11:57 pm
Quote

The move from 8 to 32 bit architecture might get me a 4x speed improvement, so I would need another 3x clock speed improvement also

Not necessarily. It is possible to make up that much through software optimizations sometimes
Title: Re: What's this I found on eBay?
Post by: PaulRB on Sep 14, 2014, 07:08 am

Quote

The move from 8 to 32 bit architecture might get me a 4x speed improvement, so I would need another 3x clock speed improvement also

Not necessarily. It is possible to make up that much through software optimizations sometimes


My GoL algorithm processes cells in parallel for groups of 32 / 64 cells stored as a long or long long unsigned int. The 8 bit Arduinos I have run it on so far have to deal with this data in 4 or 8 byte operations. I'm hoping the ARM can do this more efficiently in 1 or 2 operations.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Sep 14, 2014, 10:19 am
I also had a problem with speed on the 328, I adapted the TVout library (which is mono) so that it multiplexed with 3 channels of PWM to create a 24bit TVout library ! well sort of only one colour at a time. I had to up the processor speed as I was also receiving DMX (250kbps) through the UART constantly AND trying to do heaps of math to create shapes and patterns from the DMX data.

See here -> https://www.youtube.com/watch?v=RV49tQ6Lilc (https://www.youtube.com/watch?v=RV49tQ6Lilc)

16mhz just wouldnt cut the mustard as there is a lot of processor time used on creating the video without any visual glitches !
Title: Re: What's this I found on eBay?
Post by: PaulRB on Sep 15, 2014, 03:37 pm
That all looks very impressive, but what exactly am I looking at in that video?
Title: Re: What's this I found on eBay?
Post by: mcnobby on Sep 15, 2014, 03:44 pm
lighting effects that go through smoke, for DJs & bands etc
Title: Re: What's this I found on eBay?
Post by: PaulRB on Oct 01, 2014, 12:19 am
My Maple-Mini-Clone finally arrived today. Got it working after a little struggle. Uploaded a basic blink sketch and it works!

The problem I am having/had was that:
1. It doesn't reset when the Maple IDE tries to use DTR. I have to hit reset every time to upload a sketch.
2. I was getting a message: "Couldn't find the DFU device: [1EAF:0003]". I am running Ubuntu 14.04. I eventually found out how to fix this:
Code: [Select]
sudo apt-get install libusb-0.1-4:i386

Anyone else get theirs yet?
Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 01, 2014, 01:12 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

My Maple-Mini-Clone finally arrived today. 

Anyone else get theirs yet?
My tracking number says "In transit"... I have 3 coming, so work out the bugs! (please)
I have been working with the PSoC 4200 ARM units, so I have about 90 days of beyond-Arduino there.  The 810 guys in another thread have their 8-pin ARM programming under Arduino... Pretty cool.

Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 01, 2014, 01:58 am
Independantly of seeing this thread I ordered on of these yesterday, so I'm interested to hear other people's outcomes

I hadn't actually realized it was a Maple clone, but I guess that makes sense.

I wasn't even sure whether it could be programmed directly or needed a jtag programmer, so also ordered a jtag programmer

http://www.ebay.com.au/itm/New-ARM-Emulator-ARM7-ARM9-ARM11-Cortex-M3-J-link-V8-ADS-IAR-STM32-JTAG-Tide-/161424630350?pt=AU_B_I_Electrical_Test_Equipment&hash=item2595a8624e

and also one of these

http://www.ebay.com.au/itm/ARM-Cortex-M3-STM32F103C8T6-STM32-Core-Board-Minimum-System-Development-Board-/301247607101?pt=AU_B_I_Electrical_Test_Equipment&hash=item4623c1b13d

Though the last one is not Arduino compatible as far as I'm aware

But it was worth a look for a few $

BTW.
Again, not sure if its that useful, or if its been mentioned in this tread, but there is a non Arduino IDE called CooCox that supports STM32 so may be useful. (however I've not even downloaded it myself as I don't have any of the hardware yet, and it will be weeks before it arrives from HongKong
Title: Re: What's this I found on eBay?
Post by: PaulRB on Oct 01, 2014, 11:41 pm
Got my Conway's Game Of Life sketch running on the Maple Mini clone this evening and set a new record for generations per second on a 128x64 OLED display!

http://forum.arduino.cc/index.php?topic=216369.msg1904367#msg1904367
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 02, 2014, 02:13 am
Super cool

Can't wait for mine to arrive

Perhaps I should buy another

PS. How are you connecting  it to the PC, it looked like the connector at the end had USB signals on it, but was not a USB type plug

Did you make your own cable, or did the one you buy have USB plug on it ?


Just realised that the other end has a micro usb.

Also just ordered another one. Still waiting for the first one, but I should have bought 2.
I normally buy in two's in case I blow the first one up (which has been known to happen)

Really looking forward to it arriving

I wonder if it works with I2C and if so how fast.

I have some OLEDS but they are I2C and I'm also interested in reading motion data from an MPU9150 which is also I2C
Title: Re: What's this I found on eBay?
Post by: bobcousins on Oct 02, 2014, 06:53 am
I ordered some Maple Minis but not received yet, but I did get an IteadMaple which I think has the same chip.

It seems that Leaflabs are pursuing other interests nowadays and their IDE is not actively supported. I am looking at creating a Maple package for the 1.5.x IDE, it should be straightforward.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 02, 2014, 06:58 am
Quote
I am looking at creating a Maple package for the 1.5.x IDE, it should be straightforward.


I'd be happy to help when I actually get some hardware

I'm using 1.5. beta because I have a couple of Due boards


Title: Re: What's this I found on eBay?
Post by: PaulRB on Oct 02, 2014, 07:49 am
I would be willing to help testing that too. I run ubuntu 14.04 on my pc, although I would not call myself an advanced ubuntu user.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Oct 02, 2014, 08:50 am
Mine has arrived... up to my nuts in other work, but will find time to at least blink it !! :)
Title: Re: What's this I found on eBay?
Post by: westfw on Oct 02, 2014, 10:12 am
Went to "ARM TechCon" (http://www.armtechcon.com/ )  Scored an ST CM0 Nucleo board (STM32F072) (I was specifically hoping to find an M0 development board.  I've already got M3 and M4 boards of various sorts.)
Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 02, 2014, 05:39 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Hi, West,

For $4, you can get the PSoC 4200 which is an ARM M0+ uC.
Only 4K SRAM and 32K Flash and runs at 48MHz.

However, the learning curve of the Cypress tools is pretty steep (but all free); although once the hill is climbed, the view is fantastic!  The 4200 PSoC has 4 Configurable Digital Blocks which can morph into lots of really neat hardware: from OpAmps to USARTs.

Ray
Title: Re: What's this I found on eBay?
Post by: mart256 on Oct 02, 2014, 07:24 pm

Hi, West,

For $4, you can get the PSoC 4200 which is an ARM M0+ uC.
Only 4K SRAM and 32K Flash and runs at 48MHz.



I did a quick overview to PSoC and I didn't like the way you program it. Doing the code you have to deal with blocks diagrams (don't you?) and I think that's annoying (maybe for others that's easier).
Title: Re: What's this I found on eBay?
Post by: bobcousins on Oct 02, 2014, 08:41 pm

For $4, you can get the PSoC 4200 which is an ARM M0+ uC.
Only 4K SRAM and 32K Flash and runs at 48MHz.

However, the learning curve of the Cypress tools is pretty steep (but all free); although once the hill is climbed, the view is fantastic!  The 4200 PSoC has 4 Configurable Digital Blocks which can morph into lots of really neat hardware: from OpAmps to USARTs.


I like the sound of $4 dev board :) I just need to find somewhere I can order without paying $15 delivery charge :(

Would it help the learning curve if there was support within Arduino IDE for Psoc 4?
Title: Re: What's this I found on eBay?
Post by: westfw on Oct 03, 2014, 12:55 am
Quote
Doing the [PSoC] code you have to deal with blocks diagrams (don't you?)

No, the "block diagram" part is for defining the reconfigurable hardware that is unique to the Cypress parts.
The actual code is just ordinary C.  For an arduino-like environment, the hardware would probably get configured in "the core" and a user would not have to deal with that part of things.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Oct 06, 2014, 07:39 pm
just been looking at http://leaflabs.com/docs/ide.html (http://leaflabs.com/docs/ide.html) for info about how to install the IDE etc for the MapleLeaf ST32 I bought...

It seems its quite out of date and the IDE might only run on XP, it will run on w7

Quote
Note that while these instructions work on Windows XP, changes in Windows 7 (and later) mean that you won't be able to install the IDE without disabling driver signing on your computer. Users on the forum have reported a workaround, but we only officially support the IDE on 32-bit Windows XP.


I dont have an XP machine, and not really sure about disabling the driver signing thing....

:(
Title: Re: What's this I found on eBay?
Post by: mcnobby on Oct 06, 2014, 07:50 pm
and I just found this... the solution ??

http://wiki.leaflabs.com/Maple_IDE_Windows_8_Installation (http://wiki.leaflabs.com/Maple_IDE_Windows_8_Installation)
Title: Re: What's this I found on eBay?
Post by: bobcousins on Oct 06, 2014, 08:07 pm
I recently installed Maple IDE to verify my Iteadmaple works. The IDE runs ok on Win7 64 bit, I did have the issue with the DFU driver install. I followed the route of creating a new INF file using libusb. I also had an issue with Teensy incorrectly installing a driver for the USB serial.

The inf-wizard instructions are as follows, from this thread http://forums.leaflabs.com/topic.php?id=73, see post by Bionic-Badger.
Quote
Step-by-step instructions:

- Download the binary libUSB package (http://sourceforge.net/projects/libusb-win32/files/), extract somewhere (we'll call it c:\LIBUSB)
- Plug the Maple board into the computer
- Open Device Manager
- Switch Maple board into continuous Bootloader mode (hit reset until you get the fast blinks followed by slower blinks; reset again and immediately hit and hold the boot "BUT" button until it changes into slow blink mode, release).
- It should show some broken USB device in your Devices, not a com-port
- Run the libusb INF wizard (c:\LIBUSB\bin\x86\inf-wizard.exe)
- Click through the dialogs, the default values should be fine, or you can fill in some descriptive info
- Save the INF and have it install. It'll produce a big red prompt about the driver being unsigned and problematic; however, it will still work.
- "Update" the MAPLE 003 device in your device manager and select the INF file you generated.


On Win7 you can install unsigned drivers, but I think Win 8 can only be done after changes to bootup. I am considering getting a certificate in order to create signed drivers for this sort of thing.

However, you may be interested to know I have created an initial version of Maple support package for Arduino IDE 1.5.x series, the repo is at https://github.com/bobc/maple-asp. It still needs some work, but if you have a Maple Rev3+ board you should be able to compile sketches and upload, with the board in perpetual bootloader mode.

So far I have only run a blinky, so expect bugs !
Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 11, 2014, 10:09 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

My Maple-Mini-Clone finally arrived today. 

Anyone else get theirs yet?
Received all 3 today.  Will be building out the development environment next week after HVAC dude vacates my basement lab... Heat-pumps suck (my wallet every year!)

Tarket OS: win8.1 64-bit on Acer dual-core Intel 2.2GHz with 4G RAM.

Ray
Title: Re: What's this I found on eBay?
Post by: westfw on Oct 11, 2014, 10:56 pm
Hint: grab the "Nucleo" firmware package from ST,  if you want the raw libraries.  It's newer and more complete than the current "peripheral library" package...
Title: Re: What's this I found on eBay?
Post by: PaulRB on Oct 11, 2014, 11:48 pm

after HVAC dude vacates my basement lab... Heat-pumps suck (my wallet every year!)


What? I'm getting hvac and heat pump installed over next few months!

But if all goes to plan my heat pump will use less than 6KW max. (My neighbours is 36KW, by comparison)
Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 12, 2014, 12:43 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

after HVAC dude vacates my basement lab... Heat-pumps suck (my wallet every year!)
What? I'm getting hvac and heat pump installed over next few months!
But if all goes to plan my heat pump will use less than 6KW max. (My neighbours is 36KW, by comparison)
Well, I installed an R410A system because at the time its performance (on charts) was superior to other formulations.  But in Atlanta, it is not unusual to have low temperatures in December, January, and February dropping below the efficient transfer temp of the thermal fluid.  So, the eHeat system kicks in a lots when cold outside.  EHeat even kicks in when the temperature drops quickly, as with a quick moving front.  Overall, I am satisfied the system saves money in dual mode, but below 45 things get pretty iffy, IMO.  My tech is a master rated extrainer for the manufactor and he has tweeked the unit, but there are lots of annoyances.


Ray

UPDATE:
Went back to eBay to see if I could reorder - the listing has changed to exclude U.S.A. delivery.  I found an alternate source for $24 for Qty. 5 if anyone is interested in U.S. shipments (free):
http://www.aliexpress.com/store/product/5PCS-LOT-leaflabs-Leaf-maple-mini-ARM-STM32-compatibility/812021_1987684783.html (http://www.aliexpress.com/store/product/5PCS-LOT-leaflabs-Leaf-maple-mini-ARM-STM32-compatibility/812021_1987684783.html)

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 16, 2014, 10:48 pm
My stm boards arrived yesterday

http://www.ebay.co.uk/itm/High-Quality-STM32F103C8T6-ARM-STM32-Development-Board-Module-For-Arduino-Tool-/251621420724?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item3a95ce2eb4


but I've not had time to do anything except to plug in via USB

But I got a message on windows 7 saying the USB device had malfunctioned.

I notice there are 2 jumper links on the top of the board, both of which are open, but as I don't have any docs on the board yet, I don't know what they do.

Has anyone found anything else out about these boards.

I will contact my ebay supplier to see if they have any information.

Edit.
Found this which appears to be the original manufacturer or designer but its in Chinese

http://item.taobao.com/item.htm?spm=a1z10.1.w4004-386456545.4.uccftZ&id=22097803050

I will need to run it through Google translate

Unfortunately the pictures seem t suggest its only programable via slink, and my programmer hasn't arrived yet, unless it does something different when I change the jump links, it looks like I will have to wait for my programmer

I guess I should have also ordered one of the maple mini clones, but just this unknown board.

Did anyone else buy one of these or is it just me ;-)
Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 16, 2014, 11:34 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


I am having issues with the Maple clone under 8.1 Windows. I disabled driver signing and was able to install the ASP driver and the virtual com port, and the devMgr sees Maple003 but I am unable to get either the older Maple IDE or the latest Arduino1.5.x to use the device.  Seems like the COMx port is not enumerating.

I have not tried on Win7 of XP (yet.)  Been a bit lazy as this was a side-track adventure with no end game in view.  Board looks good, however and DFU mode is obtained easily 'nuff.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 17, 2014, 12:02 am
I just took another look at my USB error, and it could just be that Windows 7 can't find a driver, its hard to tell.
I'll see if I can find and install the Maple USB driver, and perhaps this board will be recognized as a Maple mini clone, however I suspect its not got the Maple firmware installed.

I tried to use Google Translate to translate the Chinese language page on vcc-gnd.taobao.com, but as a lot of the characters were in images on in HTML, Google Translate was unable to read them :-( and I couldn't see any links to any docs.

It looks like the boards I bought definitely need a compatible JTAG programmer, and fortunately I ordered a clone from eBay a couple of weeks ago, but its not arrived yet.
Hopefully it will turn up in the next week.

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 17, 2014, 01:24 am
Unfortunately it looks like these boards  

http://www.ebay.co.uk/itm/High-Quality-STM32F103C8T6-ARM-STM32-Development-Board-Module-For-Arduino-Tool-/251621420724?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item3a95ce2eb4

Don't appear to be immediately programmable via USB.
I tried all permutations of the jump links but it doesn't seem to make any difference - the USB just comes up as unrecognised device  and no hardware ID's are shown,
I suspect they are just put there for developers to use to allow configuration to be read, i.e if the board had a boot loader

I will check later to see if Linux e.g. lsusb shows anything.


I'm going to order a couple of leaf mini clones as well as waiting for my jtag programmer to turn up.

I suspect it could be possible to burn the maple bootloader onto this board, but as it only has 2 buttons, But perhaps it could be changed to use the jump links (assuming the source is available)

Or perhaps there is another more Arduino compatible that could be used e.g. something like the Due boot loader

Anyway, I guess I need to wait for my JTag / STLink programmer to arrive before I can do anything with these boards

Title: Re: What's this I found on eBay?
Post by: mcnobby on Oct 17, 2014, 08:40 am
I havent even got round to looking at my one yet, mine is a MapleLeaf clone from eBay
Title: Re: What's this I found on eBay?
Post by: westfw on Oct 17, 2014, 09:08 am
The 103c8t6 does not include a USB bootloader in rom, though it does have a serial bootloader.   I would assume that you can put a USB capable bootloader on the chip, but it's not there by default.   I don't know whether the maple IDE assumes the st bootloader, or something custom, but a random eBay st board is probably bare.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 17, 2014, 10:11 am
Quote
though it does have a serial bootloader.


Do you mean a JTag compatible bootloader or RS232 type serial.

Looking at the connections on my board, they are labeled GND, DIO and DCLK (as well as 3.3V) so I suppose you mean a sort of JTAG serial interface ?

Title: Re: What's this I found on eBay?
Post by: westfw on Oct 17, 2014, 11:00 am
I don't know what the board has done.  The chip supports a serial bootloader on its Usart0 interface, via fiddling wit,h the boot0 and boot1 pins.  Hopefully the Usart pins are accessible on  the board even if it means connecting to  random spots.  You only need rx and rx...

I'm away from home at the moment (Disneyland!) and can't look up the specifics.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 17, 2014, 11:04 am
Thanks @westfw

Hopefully my hardware programmer may come next week, so I think I'll hold on until it arrives, rather than attempting to find those pins, as they don't seem to be broken out onto the edge of the board.

Enjoy Disneyland

Edit.

I took a look at the ST tech notes, and I see what you mean about the boot pins.

The board appears to have the boot pins connected to the jump links, so I guess I can select the appropriate boot mode and connect a USB to serial adaptor to the Rx and Tx pins.

However I've yet to work out what software communicates with the Stm  microprocessor in this mode.

So I need to do more research
Title: Success with mini-Maple on Windows 8.1 64-bit
Post by: mrburnette on Oct 17, 2014, 06:16 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Success using the Maple IDE on Windows 8.1 64-bit professional via DFU mode.

- Driver signing must be disabled for the session duration (Google for several approaches)
- Update the DFU-Util https://dl.dropboxusercontent.com/u/54378433/dfu-util/dfu-util.exe (https://dl.dropboxusercontent.com/u/54378433/dfu-util/dfu-util.exe)
- Use libusb-win32-bin-1.2.6.0 utility installer_x utility to create an INF file (Maple must be plugged into USB)
- Point Control panel to the new INF and install

In the Maple IDE 0018, bring up the Blink Example and use File/Upload to I/O Board to upload the compiled sketch.  The mini-Maple needs to be in permanent DFU mode.

Disclaimer, some of the above may be short-circuited but hopefully this will get you into the ballpark with the mini.

Now, hopefully bobcousins will get is all working under Arduino 1.5.7.  HOwever it appears that unless someone finds a way to enumerate the COMx port of the Maple under Win8.1, the DFU-Util will still be needed unless the Arduino IDE has a hook to replace AVRDUDE.  (I thought I had it, but I'm getting a library path error: arm-none-eabi-g++: error: C:\Program Files (x86)\arduino_157\hardware\maple-asp\Maple\variants\maple/libmaple.a: No such file or directory)  Maybe tomorrow with a fresh cup of coffee?


Ray
Title: Some progress with STM32 board
Post by: rogerClark on Oct 18, 2014, 08:39 am
Taking @WestFm's advice, I've managed to communicate with my STM32 board (that looks a bit like a Maple Mini) i.e
(http://i.ebayimg.com/00/s/ODAwWDgwMA==/z/r9UAAOSwRLZT8xto/$_57.JPG)

But I can only get serial to work.

I have tried the 2 boot pin links in all positions and I although a USB device appears, regardless of Link settings, it just comes up as unknown device on Windows 7, and I tried using the DfuSe from ST's website and also the one that mrburnette posted, but neither seemed to recognize the USB device.

I have yet to try it on XP or Linux, so I guess there is a chance one of those may behave differently

Anyway. I did manage to connect to the board using a USB to serial connector which I normally use to program Arduino Pro Minis' , using the ST's "Flash Loader Demo"

However all I've done so far is to see if I could download, and unfortunately I have a driver issue with my USB to Serial which causes Windows to crash into blue screen sometimes, which us what happened using the Flash Loader.

So I guess my next step is probably to see if I can upload the Maple Mini bootloader onto my STM32 board.

So I'll post to the forum and update if I manage to do that


Edit.

Just uploaded Maple_mini_boot.bin to the board via serial, and the board is now reporting as Maple 003
Hardware ID's

USB\VID_1EAF&PID_0003&REV_0201
USB\VID_1EAF&PID_0003

The next step will be installing the Maple driver on W7. I better download and install the Maple IDE and see how things go.

Hopefully W7 will not be as much hassle as W7, but I imagine that there are similar driver signing issues :-(


Edit 2.

I have the same driver signing issues with W7.  aarrggghhh.

Looks like the only way to load the driver is to reboot and temporarily disable driver signing, but its a pain to need to do this each time I reboot.

Also. The board I have, doesn't have the LED on the same pin as the maple board and also doesnt have 2 push buttons, it only has a reset button, but looking at the Maple mini schematic, its easy to wire another led and it looks like i can use the jump links as the push button, as long as I connect PB8 to the Boot0 link.
(Maple has the LED on PB1, it looks like the LED on my board is on PC13)
I'll need to wire up the LED otherwise I can't see it flashing during startup, to work out when to use the jump link to trigger the various USB configs required for the full setup.




Title: Re: What's this I found on eBay?
Post by: bobcousins on Oct 18, 2014, 01:52 pm
@roger  You are doing well :)

I also got one of those boards, hadn't got round to programming it yet. I've been searching for schematic or other info,  I can't find one anywhere.

I managed to install the Maple drivers ok on Win7 64 bit even though they are not signed. Btw, PID=0003 should be the libusb DFU device, and PID=0004 is the USB serial device.

I think that BOOT1 jumper should normally be set to zero. BOOT0 is the equivalent of BUT button on Maple boards, ie. jumper to 1 /after/ reset (during fast LED flashing) to get into perpetual bootloader, otherwise the jumper should be set to 0 to run user sketch.  If BOOT0 is 1 at reset, the chip will enter the ROM bootloader (UART).
Title: Re: What's this I found on eBay?
Post by: bobcousins on Oct 18, 2014, 04:11 pm
Good news :D

I have now tested Maple-ASP on Windows 7 and 8 (64-bit) and hopefully ironed out most of the bugs. It supports Maple and Maple Mini boards with Maple bootloader already installed.

I discovered exe and dlls were not in the github repo, sorry about that!

I have included drivers for Maple serial and Maple DFU which should install as unsigned drivers on Win7, you will need to disable driver signing on Win 8 to install.

You need to install drivers twice, once when the Maple board is in bootloader (DFU driver) and once again when the Maple is running a sketch (Maple serial port). Possibly the DFU driver can be installed using the libusb installer, I didn't try that. Either way you must pre-install the DFU driver before downloading a sketch.

I'll look at bundling a bootloader and UART programmer to allow native downloads. I'll also like to create a target for the non-maple boards, and maybe an installer. Any help with Linux installation would be appreciated :)

Most of the information in the Leaflabs doc still applies, http://leaflabs.com/docs/

My install process was as follows:

1. Download and install Arduino 1.5.7  http://arduino.cc/en/main/software
2. Download and install Maple-ASP zip file (NB must install into sketchbook!) https://github.com/bobc/maple-asp/archive/master.zip
3. If Windows 8, reboot with options, disable driver signing   https://learn.sparkfun.com/tutorials/disabling-driver-signature-on-windows-8/disabling-signed-driver-enforcement-on-windows-8
4. Plug in maple board. Install Maple serial driver from "Documents\Arduino\hardware\maple-asp\drivers"
5. Set board to perpetual bootloader mode. Install Maple DFU driver from "Documents\Arduino\hardware\maple-asp\drivers"
6. Run Arduino IDE
7. Select Boards->Maple and COM port as appropriate.
8. Load Blinky sketch. Edit LED pin to "BOARD_LED_PIN"
9. Upload!
Title: Re: What's this I found on eBay?
Post by: PaulRB on Oct 18, 2014, 06:44 pm
Hi bobcousins, how much of that would you expect to work on linux? I use Ubuntu 14.04, Arduino 1.0.5 (1.5 not available on Ubuntu s/w centre yet) and have a Maple Mini clone, which I can program with Maple ide for the moment (but obviously a single app which does Arduino and Maple would be better).

Thanks,

Paul
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 18, 2014, 09:55 pm
Hi bob,

I've taken a closer look at the schematic of the maple mini versus the hardware of my STM32 board and it looks like there are some more hardware differences that will prevent it working as a maple mini clone.

The maple mini schematic shows two transistors configured to do something with the D+ line of  the USB.
As far as I can tell the generic STM32 board doesn't have this.

Also the generic board appears to have a RTC device on it, well according to the photo on the vcc gnd website, that's what one 4 pin IC on the board is supposed to be.

If it needs 2 transistors etc in order to work with the maple driver, I will probably not bother adding all other components, and instead just use the boards with some other dev system e.g coocox.

But I will try just adding the led and connecting the other line to boot0.

I have 2 of these generic boards, so I'm also going to try to get hold of the USB bootloader that is supposed to be installed on the STM primer boards, and put that bootloader on my other board, so that I can flash using the ST USB uploader, rather than needing to use Serial.

I'm not sure if coocox works directly with the ST USB bootloader, but I also have a Chinese clone STLINK module in the post, so I will be able to get these board fully working sooner of later

Edit.

I connected a LED to PB1 and it flashes as expected, given the firmware is for the Maple mini. However I was unable to get the board to go into DFU mode.

I soldered a wire between PB8 and my Boot0 jump  link (is the jump link in the center of the board), and followed the instructions,. on the maple wiki, which basically pull boot0 and high while the led is flashing quickly.

But I couldn't get it to work.

The wiring of these generic boards has 100k in series with boot0 and the jump link, and I was unable to directly solder PB8 to Boot0 on the IC without damaging the IC. (I tried a few times but you would need a microscope to do it successfully)

I also tried pulling PB8 to 3.3V via a 1K via a push button, in case the issue was the 100k, but it didn't make any difference.

Also unfortunately i managed to snap the connections to the micro USB whiile trying to press and hold the button and move the jump links etc.

Fortunately, I managed to re-flow the solder back onto the USB pins

But I think i'll need to give up using these generic STM32 boards as a Maple Mini, because its possible that in order for the DFU mode to run, I'd need to wire in the 2 transistors that are connected to D+ and I'd probably damage the board doing that :-(

I'll have to wait for my other Maple Mini clones to arrive in the post in a few weeks
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 18, 2014, 10:05 pm
I'm not sure if this is relevant but I've noticed this

https://www.microduino.cc/

https://www.microduino.cc/wiki/index.php?title=Microduino-CoreSTM32

Which seems also to use the maple IDE etc.

It looks like they may have just cloned the maple design,  and put it in a different form factor.

But I have not tracked down their schematics yet.

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 19, 2014, 02:27 am
Bob,

I'm not sure what I'm doing wrong, but I just thought I'd try to compile in the Arduino 1.5.7 Beta IDE and possibly just upload the bin file to my generic STM32 board, but I get a load of warnings

Build options changed, rebuilding all
In file included from C:\Users\theuser\Documents\Arduino\hardware\maple-asp\Maple\system/libmaple/include/libmaple/stm32.h:70:0,
                from C:\Users\theuser\Documents\Arduino\hardware\maple-asp\Maple\variants\maple_mini\libmaple\stm32f1\performance\isrs.S:29:
C:\Users\theuser\Documents\Arduino\hardware\maple-asp\Maple\system/libmaple/stm32f1/include/series/stm32.h:86:0: warning: "STM32_MEDIUM_DENSITY" redefined [enabled by default]
#   define STM32_MEDIUM_DENSITY
^
<command-line>:0:0: note: this is the location of the previous definition
In file included from C:\Users\theuser\Documents\Arduino\hardware\maple-asp\Maple\system/libmaple/include/libmaple/stm32.h:70:0,
                from C:\Users\theuser\Documents\Arduino\hardware\maple-asp\Maple\variants\maple_mini\libmaple\stm32f1\performance\vector_table.S:29:
C:\Users\theuser\Documents\Arduino\hardware\maple-asp\Maple\system/libmaple/stm32f1/include/series/stm32.h:86:0: warning: "STM32_MEDIUM_DENSITY" redefined [enabled by default]
#   define STM32_MEDIUM_DENSITY
^
<command-line>:0:0: note: this is the location of the previous definition

Sketch uses 10,076 bytes (9%) of program storage space. Maximum is 108,000 bytes.


Is this normal ?

Edit.
Tried as a matter of interest, uploading the blink sketch compile in the Arduino, via the UART Flash Loader (ST), but I can't see any of the GPIO lines toggling.

Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 19, 2014, 02:56 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


In Windows, it is in %temp% in a subdirectory shown when the IDE is in verbose mode.

Added...

I wrote a script a long time ago to find and move a file(s) [the most recent nested version of a filename] from the current working directory!  You do not need to know where it is as the script will ferret the issues for you.  I did the Win version and a few other members chimed in with Linux/osX

http://forum.arduino.cc/index.php?topic=196101.0 (http://forum.arduino.cc/index.php?topic=196101.0)


Ray


Windows 8.1 script for Arduino 1.0.6

Code: [Select]

PATH=%path%;C:\Program Files (x86)\Arduino_106\hardware\tools\avr\bin;
C:
CD %TEMP%
MD %PUBLIC%\ELFtemp
for /R %TEMP% %%f in (*.elf) do XCOPY /D /Y %%f %PUBLIC%\ELFtemp\
DIR %PUBLIC%\ELFtemp\*.elf /s /b /O:-D /T:W >ElfRhere
SET /P ELF= <ElfRhere
ECHO %ELF% >MemUsage.txt
AVR-SIZE -C %ELF% >>MemUsage.txt
NOTEPAD MemUsage.txt
CD %PUBLIC%\ELFtemp
ECHO y | DEL *.* \%1
SET ELF=""
Title: Re: What's this I found on eBay?
Post by: Paul__B on Oct 19, 2014, 04:48 am

Arduino ... 1.5 not available on Ubuntu s/w centre yet

That's a bit of a pain - apparently no-one around who simultaneously uses Arduino and is guru for the Update Centre.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 19, 2014, 05:04 am
@mrburnette

Thanks.

I turned on verbose and found where the bin files were being written, but I cant get the bin files to run by directly uploading them into the Flash of the device, i.e in place of the bootloader.

i.e I tried the Maple blink example, and I have an LED connected to the Maple LED, but I didnt get any flashing. I looked at all the other GPIO pins with my analogue multimeter to see if any of them were toggling, but none were.


Would you expect a bin file that was flashed onto the device using the ST flash uploader tool, to run ? 
Perhaps this isn't possible because I don't have the Maple bootloader installed any more, i.e I'm overwriting it with the actual sketch (bink), so it could be some sort of memory mapping issue e.g. calls to non-relative function address points.
Title: Re: What's this I found on eBay?
Post by: bobcousins on Oct 19, 2014, 12:30 pm

Would you expect a bin file that was flashed onto the device using the ST flash uploader tool, to run ? 
Perhaps this isn't possible because I don't have the Maple bootloader installed any more, i.e I'm overwriting it with the actual sketch (bink), so it could be some sort of memory mapping issue e.g. calls to non-relative function address points.


Your hunch is correct, the current Maple targets assume the presence of the Maple bootloader, so the sketch is linked to start at an address above the bootloader. There is a link option for non-bootloader in libmaple, it should be easy to add an option to the boards list in the IDE. I was planning to use the stm32flash tool to download using the UART pins.

Btw, the two warnings about redefined macros are a nuisance but not a problem.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 19, 2014, 11:29 pm
Thanks Bob,

Thank makes sense.

I may need to get back to you about enabling that link option if I can't figure it out myself ;-)

Uploading via the uart works fine for me, but it looks like even with the boot0 pulled high, the board only seems to be listening for serial traffic for less than a second.

I.e if I enable flash uploading with the jump link, the reset, then use the flash uploader straight away, it works.
But if I reset and wait a second or two, the ST flash program fails to connect, and I have to reset the STM board again.

I was initially under the impression that with the boot pin pulled high that it was permanently in boot mode, but this doesn't seem to be occurring for me.
I will need to re read the docs ;-)


Either way, using the Arduino / Maple libs would make using this board far easier than the alternatives I've looked at.
E.g. I downloaded coocox, but couldn't even manage to get a version of blink to work ;-(

I was going t download Keil as I've now seen that you can use Keil with gcc and thence get around the 32k code limitations. But I'm not sure Keil is going to be an easier programming experience than coocox.
But its probably worth a look.

However if I could get the Arduino / Maple libs working, it would make porting any existing code to this board far far easier


Thanks again

Roger
Title: Re: What's this I found on eBay?
Post by: bobcousins on Oct 20, 2014, 01:15 am

Hi bobcousins, how much of that would you expect to work on linux? I use Ubuntu 14.04, Arduino 1.0.5 (1.5 not available on Ubuntu s/w centre yet) and have a Maple Mini clone, which I can program with Maple ide for the moment (but obviously a single app which does Arduino and Maple would be better).


Compiling seems to work ok, I am working on the download, I think it just needs a few changes to the scripts.

It should be possible to use dfu-util from a command line to download the binary if you have run the "install-udev-rules.sh" script, and put the board into perpetual bootloader mode. The command is something like

dfu-util /dev/ttyACM0 -a 1 -R -d 1EAF:0003 -D file.bin
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 20, 2014, 02:23 am
Hi Bob

Quote
It should be possible to use dfu-util from a command line to download the binary if you have run the "install-udev-rules.sh" script, and put the board into perpetual bootloader mode.


I can't seem to get the board into perpetual bootloader mode.

The real Maple Mini has a pair of transistors which pull USB D+ to GND under software control, which I presume is use to force the PC to re-enumerate the USB devices.

However the generic board doesnt have this. So I think this is why I can't get it into perpetual bootloader mode.

I will try compiling with that option to link from the base of memory rather than above the bootloader, but I'm not sure whether Serial USB would then still work, as if that functionality is inside the bootloader it won't work.
(Unless Serial USB is in the Maple Lib as well as in the bootloader ???)

One other option may be to see if I can get the "sketch" to be uploaded into a different memory address, I noticed some options.

And I've noticed a python based loader https://github.com/jsnyder/stm32loader  that seems to have an option for target address.

Do you know the address that the bootloader normally places the code that it receives ?

This would probably be the easiest option to get around the issue of the bootloader being missing and the linker using the wrong addresses

Edit.

I've not tried it yet, but looking in the Maple bootloader source code  config.h it has these defines

Code: [Select]
#define USER_CODE_RAM ((u32)0x20000C00)
#define RAM_END ((u32)0x20005000)
#define USER_CODE_FLASH ((u32)0x08005000)
#define FLASH_END ((u32)0x08020000)


Which looks suspiciously like the address of the flash and also the ram address of program uploads

When I get chance (this evening), I'll reflash the maple bootloder back onto my STM board and then build the maple "blink" example, and try uploading it to 0x08005000 (assuming I select the board definition to upload to flash)

I'll let you know how I get on.


Title: Re: What's this I found on eBay?
Post by: bobcousins on Oct 20, 2014, 09:52 am

The real Maple Mini has a pair of transistors which pull USB D+ to GND under software control, which I presume is use to force the PC to re-enumerate the USB devices.

However the generic board doesnt have this. So I think this is why I can't get it into perpetual bootloader mode.


That is a good observation! The Maple bootloader scheme hinges around being able to re-enumerate as a DFU device, so disconnecting the USB via the pullup is essential. I think this board has the pullup hardwired (still haven't found a schematic), which would require unplugging the USB cable to re-enumerate.

There is some info on the Maple bootloader here http://static.leaflabs.com/pub/leaflabs/maple-docs/latest/bootloader.html, clearly they had problems with their initial scheme.

Perhaps a simple Arduino style bootloader would be better for this board, using an FTDI serial to reset and enter the STM32 UART bootloader, then use something like stm32loader. Another option is STLINK.

To build a sketch for stm32loader (not using Maple bootloader), change the line in maple-asp/Maple/config.txt

maple_mini.build.ldscript=ld/flash.ld

to

maple_mini.build.ldscript=ld/jtag.ld

which gives it all of Flash and Ram to run in.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 20, 2014, 10:28 am
Hi Bob,

I think the schematic to the maple mini is here

https://github.com/leaflabs/maplemini (https://github.com/leaflabs/maplemini)

I don't have the schematic to my generic STM321 board, but as far as I can see it doesn't have much apart from jump links for Boot0 and Boot1 and also a connection to an RTC (not sure how the RTC is connected I will need to look to see what device it is)

Re: Uploading

I tried setting the board to "Leaflabs Maple Mini Rev 2 to Flash" built with verbose turned on (So I could see where Arduino put the bin file), then uploaded to flash address 8005000 (using ST's tool, but after a reboot, the board just flashed the LED like it does when just the bootloader is installed.

However if I checked the option in the upload tool for "Jump to the user program" it started to flash the :LED at one second intervals, so it was definately running the blink sketch

I tried rebooting (with Boot0 not held high), but the maple bootloader  doesn't seem to execute the user program.
Looking at the bootloader code

It has this line

Code: [Select]
bool no_user_jump = !checkUserCode(USER_CODE_FLASH) && !checkUserCode(USER_CODE_RAM) || readPin(BUTTON_BANK, BUTTON);

So I think the reason its not running my code after boot is because USER_CODE_FLASH has not been set.

I think I can manually set this using the ST Flash Loader tool once I figure out its address (watch this space)

Re:Using FDTI instead of the complex DFU etc

Yes. My thoughts exactly.
It would then behave just like an Arduino Mini etc which need an external serial adaptor, which I'm quite used to using on this size of board.

I'm actually thinking of attempting to recompile the Maple bootloader, but cheat and change the hardware ID of the USB serial, so that it thinks its a serial device from a different manufacturer. However I'm not sure if its just a question of changing the ID's or whether the maple USB serial code in the bootloader is a non-standard usb serial.

Anyway, first things first, I'm going to see if I can manually set that flag so that the bootloader always thinks there is user code installed ;-)


Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 20, 2014, 10:48 am
OK. I figured out why it was not executing by program, its because I don't have a button attache to PB8 (like the maple mini does)

Actually, I looked at those addresses and they are the Flash start and Ram start addresses, so its looking for code not a flag.
i.e 0x8005000 for flash.
I read back what I"d uploaded and I could see that the program was still in flash after a boot,

and that the first 4 bytes were 00 50 00 20 and the code was looking for 200000 so allowing for memory byte orientation, the pattern was correct

So what I need to do is pull PB8 low all the time, via a resistor to stop it floating.

Then the boot process is quite slow, it flashes 6 times quickly, then does slow flashing for a few seconds and then finally gets around to running the user code

It takes much longer to load than the arduino bootloader

Next step to to see if Serial works (after I reboot to use the unsigned driver)
Title: Some success with generic STM32 board
Post by: rogerClark on Oct 20, 2014, 10:11 pm
I tried to use the SerialUSB commands, but the code appeared never to get
SerialUSB.available() to be true, and hence it seemed to hang in setup()

This could be something to do with the board not being able to do its re-enumeration stuff because it doesn't have those transistors attached to the USB D+ line.

Anyway, as I'd already got my USB to serial attached to USART1 (pa9 and pa10), I tried using Serial1 instead and it worked fine.

My STM32 board has an led on a different GPIO to the maple mini, it has the led on PC13, and for a while I was struggling to work out the mapping of the STM32 GPIO pin names to the Arduino PIN numbers, but I found there are enums for them, so it was possible to write

pinMode(pc13,OUTPUT);
digitalWrite(pc13,HIGH);


To get the maple bootloader to run the code after booting, I had to make sure that pb8 was pulled low, as this is attached to a button on the maple mini. So I pulled low via 1k in case I accidentally drove that pin via digitalWrite

I was not able to test loading into the base flash address (0x800000) as the forum went offline before I wrote down bobs instructions to make a new board config, but I will do that today.

Currently, to upload, I have boot0 pulled high, and am using the ST flash loader tool, as it has an option to load at the correct address 0x8005000 and jump to and run code at this address.

So I build in the Arduino IDE the run the flash tool, press the reset button on the board, and then quickly press Next in the flash loader. This seems to put the board into communications with the flash loader and you can then progress to the other screens in the tool and upload and run the code.

Currently the upload process is a bit of a pain.

I did look at using the st32loader python script, and although it appeared to upload to the board, there is not an option to jump to the user code, and even if I rebooted with Boot0 pulled low, the code uploaded by the python script didn't run.

However I have not had time to figure out why this is.

I'm using the python script that is part of the maple tools, but as far as I can tell is not used by the Arduino build process.

I'm not sure how up to date the version of the script is, so I also need to try the latest version from GitHub  

So my next steps will be...

1. Make a board config that links to addresses starting at 800000 so that there is no need for the Maple bootloader.
2. See if I can get the python script working
3. See if I can get the python script to run as part of the Arduino Upload command
4. Ideally there would need to be some way to automatically put the board into serial upload mode only when required.
Probably the best way to do this would be an arduino style bootloader and external USB to serial, e.g I think this is what the Due does.
However this sounds like a lot of work, and for the moment I will just fit some additional push buttons to the board so I can do this manually ;-)

Edit.
I forgot to mention
I'd like to use i2c with this board, but currently the status of the I2c lib seems unclear.
I think there may be basic, bit banged support, but it appears that there are some issues with hardware i2c associated with hardware faults in the actual IC.

Anyway, I may try hooking up a simple temperature sensor and see if i can get basic comms going before attempting communication with what I really want to use, which are accelerometers etc I.e mpu9150
Title: New boards.txt with non-bootloader for STM32 via serial
Post by: rogerClark on Oct 20, 2014, 11:09 pm
In case its of any use to anyone else

I've amended Bob's boards.txt file to add a new board, which builds for flash upload without the bootloader

I've tested it using ST's uploader and its working fine.

I'm now going to try to see if I can get the python upload script working. Watch this space ;-)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 21, 2014, 01:03 am
This is probably a really stupid question, but as the Due is a ARM cortex M3 uP as is the STM32F103  would it be practical to use either the source code for libdue etc for these STM boards rather than using the old Maple code ? i.e libmaple.a
I know the Atmel chip has a lot more connections etc, but as its built on the same underpinnings, it seems to make sense to use the Due code, because the maple lib is no longer in development and has issues with various things, specifically I2C

Anyway, just a thought ;-)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 21, 2014, 05:18 am
Update on my progress or lack of it with my generic STM32 board.

Firstly I can't get the python upload to work at all, I've tied the one that is part of Bob's maple package, but that didn't work, and I also tried the latest one on github.

Strangely, the python script seems to upload OK, i.e there is code in the flash, but it doesn't seem to work.
It seems to be uploading the code, but it is doing something else that prevents the code from running, so currently the only think that works to upload the bin is the ST flash loader tool

With the Flash loader, it also only works if I only erase the necessary pages. Global erase seems not to work.
At the moment I'm really not sure what is going on and why either the Python loader or another windows exe loader I've tried, don't work. Yet the ST one does. :-(





Title: Re: What's this I found on eBay?
Post by: westfw on Oct 21, 2014, 07:17 am
Quote
would it be practical to use either the source code for libdue etc for these STM boards rather than using the old Maple code ?
No.  While ARM-based CPUs from different manufacturers have the came core CPU and instruction sets, they tend to have vastly different peripherals.   Since the Arduino core libraries consist mostly of interfacing to the peripherals, they have to be re-written for each different chip vendor (and frequently different for different families of chips.)

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 21, 2014, 08:18 am
@westfm

Thanks. That makes sense.

Title: Re: What's this I found on eBay?
Post by: westfw on Oct 21, 2014, 09:00 am
Back from Disney.  :-)  (New avatar, if the forum SW ever cooperates!)
Here's a pinout diagram I made for the STM32f103c8t6: https://docs.google.com/spreadsheet/ccc?key=0AqdMB5dovDUZdGR6cVprUnkwTV9CMUNybV9VMjF5a0E&usp=drive_web#gid=0 (https://docs.google.com/spreadsheet/ccc?key=0AqdMB5dovDUZdGR6cVprUnkwTV9CMUNybV9VMjF5a0E&usp=drive_web#gid=0) - this includes the BOOTx functionality used by the internal (ROM) bootloader.
The (builtin) bootload capabilities are described in http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf (http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf) - basically, the "small" chips like the 103 contain only a serial bootloader, while some of the larger chips can also boot from USB (via DFU), CAN, or other things.  I've been using https://code.google.com/p/stm32flash/ to program my (otherwise different) ST board; it's a rather annoying multi-step process:


Note that the ROM Serial bootloader runs "forever", while the maple bootloader only runs momentarily.

I'll see if I can get the Maple SW/bootloader running on my (not maple-like) board.  It should be possible (and useful!)


Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 21, 2014, 11:01 am
@westfm
What OS are you running, the only utility that seems to upload and run for me is the ST Flash Uploader.
I looked on that Google repo but couldnt see an exe. I tried to compile in codeblocks on the PC but had issues with missing headers, so I found a precompiled version, but although it uploaded, the program wouldnt run after upload :-(
Title: Re: What's this I found on eBay?
Post by: westfw on Oct 21, 2014, 11:12 am
I'm running on a Mac.   I didn't notice the lack of pre-compiled versions.  :-(

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 21, 2014, 11:44 am
Hi @westfm
Ah, A Mac joke ;-)
I know what you mean. I do some dev work that requires iOS versions of things, so have a mac just for that stuff.
What options did you use with stm32flash  i.e did you use erase any pages ?
I'm not sure whats happening, I can't get the programs to run at all if I upload using anything by ST's flash loader exe :-(
And even then, it seems a bit hit and miss, and I'm not sure why.
It seems to initially require me to upload to 0x8005000 in order for it to run, but this doesnt make any sense because the normal boot location is 0x8000000  so unless its running a load of nops before it gets to 0x8005000 its not going to work
I changed the linker option as suggested by Bobc, ie I modified boards,txt, so I have an STM32 board
i.e
maple_STM32.build.ldscript=ld/jtag.ld
so the rom address is set to 0x8000000  so I'm not sure why I'd need to upload to 0x8005000
I suspect its something else random thats causing uploads not to run, but I'm really not sure what
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 22, 2014, 12:18 pm
@bobc etc
I think I may have figured out why I kept having to upload to address 0x8005000 even using ld.jtag
I noticed that in board.txt there is a define for the linker like this

Code: [Select]
-DBOOTLOADER_maple

e.g.

Code: [Select]
mapleRAM.build.extra_flags=-DMCU_STM32F103CB -mthumb -MD -DSTM32_MEDIUM_DENSITY -DBOOTLOADER_maple -march=armv7-m
So as a matter of interest I took it out.
But I then got errors in usbserial.cpp and also boards.cpp inside the wirish folder
I've fixed these errors by putting #else cases in for the missing items e.g

Code: [Select]
#if defined(BOOTLOADER_maple)
    #define USER_ADDR_ROM 0x08005000
#else
    #if defined(BOOTLOADER_robotis)
        #define USER_ADDR_ROM 0x08003000
    #else
        #define USER_ADDR_ROM 0x08000000
    #endif
#endif


And I think this may have resolved the issue where it seemed to randomly require me to either upload to 0x8005000 or to 0x8000000

I still need to do some more tests to absolutely confirm this, but I think its definately something that may have caused a problem
BTW.
I've still had no luck getting I2C to work.
I used the Wire from the maple-asp IDE but that didnt work at all. I checked SDA and SCK with a scope and nothing was being toggled.
I've noticed that libmaple repo on github has a libraries folder that contains a different version of wire that uses wirish, but that version won't compile because the libraries can't access their own headers
(I know this is a common problem but I can't remember the solution, apart from possibly hard coding the full path - which sounds like a hack to me.

Title: Re: What's this I found on eBay?
Post by: JoeN on Oct 23, 2014, 03:46 am
Currently it maxes out the ram on a mega328 processing a 128x64 matrix.
Have you considered a serial SRAM IC?  It may slow you down, but then again, maybe not.

Edit:  I should have considered how old this message is but I failed to notice.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 23, 2014, 09:38 pm
Hi Joel

Yes. This thread has moved on;-)

Thanks to BobC s work it is possible to use the Arduino IDE to target several different STM32 based boards.

I think people with Maple Mini clones have managed to upload via USB.
I have a generic STM32 board that I got from eBay, that looks similar to a Maple mini but I now know, doesn't have all the necessary hardware to work with the Maple bootloader, specifically some transistors use to fore USB re-enumeration.

Nevertheless, I can successfully upload via a USB to serial adaptor, as the STM32 processor has built in bootloader that accepts a special serial format.

Unfortunately Maple seem to have given up on developing this range of boards, and some key libraries don't appear to work, specifically for me is that I2C Wire doesn't work.

I think in eventually this could be resolved, but I don't personally have the time to fix such a complex problem.

I do however like the STM32 board I have, as its as cheap as an Arduino mini and far faster and with far more ram and rom, so I may use it for projects that don't need I2C.
Title: Re: What's this I found on eBay?
Post by: westfw on Oct 24, 2014, 07:09 am
I used stm32flash in a basic form, like this:

  stm32flash -R -w hello_isr.hex /dev/tty.usbserial-FTD61T6Q


Hmm.  Reading the Leaflabs page on their bootloader issues, it seems to me that they got overly ambitious about how they wanted things to work (compared to, say, Leonardo.  Which is kludgey and not perfect, but seems to work most of the time for most people.  (On Leonardo, the bootloader also implements a serial port and runs a serial bootloader protocol.  While the sketch itself runs a second version of the usb/serial code that does the auto-reset thing when you attempt to set an "unlikely" bitrate (1200bps)))
The whole "virtual drive" thing is cute, but unnecessary, and complicated by the rarity of devices that implement both CDC and Mass Storage USB profiles...

Alas, it's probably not worth spending a lot of time on this, given that Leaflabs has "moved on", and the official ARM arduinos (Due and Zero) are using different chips (and also could use work.)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 24, 2014, 12:17 pm
Struggling with the forum in order to reply with the forum on the blink (again)

Anyway

Fixed my issues with code not running after upload

issue was the -DMaple_bootloader causing boards.h to redefine ROM to the bootloader address

I'm now using the stm32flash exe  and it seems to work every time

I'm going to see if its possible to modify the IDE to use the STM32flash uploader instead of what it would normally try to use

I presume its possible somehow in the hardware config


I'll reply about the Zero etc when the forum is more stable ;-)


Edit.

I've now managed to automate the upload process using stm32flash

Changed the maple_upload.bat to

Code: [Select]

@echo on
rem
rem
rem
rem parameters are:

rem Note: %~dp0 get path of this batch file, so path parameter is no longer required

cd %~dp0
set str=%4
set str=%str:/=\%
stm32flash -g 0x8000000 -w %str% %1



And copied stm32flash.exe into the same folder ie hardware\maple-asp\tools\win

BTW. The set str stuff is because the path to the bin has both forward and back slashes (looks like a bug to me), but fortunately I found some batch file code to replace / with \ 
Strangely you don't escape the back slash

Anyway.

the -g 08000000
tells the loader to goto (run) the code at the base address of the rom i.e 0x8000000
So I leave boot0 pin permanently pulled high via the jumper on the board, while developing

I then just need to press the reset button before I press Upload (control U) in the Arduino IDE

works a treat !

Just need to fix the I2C ;-)  (no doubt a much harder job).

PS. Shame the forum has given up sending thread updates, I think I'm not the only one with this board and several other people may find this information useful.



Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 24, 2014, 04:23 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Status update:

I have the Maple IDE working correctly with the Maple Mini clone by BAITE.  It will upload in perpetual DFU or will use the serial port to interrupt the running sketch and place the board into DFU mode.  The Maple IDE works OK.

I can compile successfully in the Arduino 1.5.7 environment but even with the USB port enumerated as a COM (working with Maple sketches sending output over the serial USB) I cannot figure out how to get Arduino to upload to the Maple mini.  I have Arduino Tools/Programmer == USBasp and the port == the enumerated serial port (COM12 on my system) and I have the board selected as == LeafLabs Maple Mini REv2 to Flash (also have tried RAM.)

Device Manager shows MapleR3 enumerated as COM12
(added) I had to delete and reinstall the USB serial driver before this would work! Win8.1 in "Test" mode because of unsigned drivers.  What a pain... thanks Microsoftbrains for nothing!

Device Manager shows Maple003 as the libuse-win32 device in perpetual bootloader mode

The error message from Arduino 1.5.7 is:
Code: [Select]
java.io.IOException: Cannot run program "dfu-util": CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessBuilder.start(Unknown Source)
 at java.lang.Runtime.exec(Unknown Source)
 at java.lang.Runtime.exec(Unknown Source)
 at CliTemplate.DFUUploader.executeCheckCommand(DFUUploader.java:206)
 at CliTemplate.DFUUploader.uploadViaDFU(DFUUploader.java:105)

 at CliTemplate.CliMain.main(CliMain.java:54)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessImpl.create(Native Method)
 at java.lang.ProcessImpl.<init>(Unknown Source)
 at java.lang.ProcessImpl.start(Unknown Source)
 ... 6 more
Couldn't find the DFU device: [1EAF:0003]


I thought I had everything configured correctly when 1.5.7 compiled everything correctly under Win8.1 64-bit, but there is still some little glitch in the system.  Not a deal-breaker since the Maple IDE works OK however I would prefer to have 1.5.7 as the primary environment (eventually!)

Ray

Title: Re: What's this I found on eBay?
Post by: bobcousins on Oct 24, 2014, 04:58 pm
The error message from Arduino 1.5.7 is:
Code: [Select]
java.io.IOException: Cannot run program "dfu-util": CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessBuilder.start(Unknown Source)
 at java.lang.Runtime.exec(Unknown Source)
 at java.lang.Runtime.exec(Unknown Source)
 at CliTemplate.DFUUploader.executeCheckCommand(DFUUploader.java:206)
 at CliTemplate.DFUUploader.uploadViaDFU(DFUUploader.java:105)

 at CliTemplate.CliMain.main(CliMain.java:54)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessImpl.create(Native Method)
 at java.lang.ProcessImpl.<init>(Unknown Source)
 at java.lang.ProcessImpl.start(Unknown Source)
 ... 6 more
Couldn't find the DFU device: [1EAF:0003]

I think that might be because I didn't check in the .exe to github! (.gitignore problem). The latest revision should be ok.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 24, 2014, 05:30 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
I think that might be ...
:D

bob,

Or it may just be me!  Seasonal allergies here in the South and the required antihistamines do make a foggy head more foggy (foggier?)

I'll re-sync my directory with your github.  That was actually on my to-do list anyway, so maybe this afternoon or this weekend, foggy-brain-syndrome willing.

At 5 units for $24 (Aliexpress) these little Maple Mini's are potentially good for users that need the speed of a Due but the formfactor of a Nano or Pro Micro ... just eyeballing one beside a Pro Micro, it looks like the 32U4 is about 66% the length of the STM32 and exactly the same width.

I am pleasantly surprised of the bang-for-the-buck but it is unknown how long such a supply would last at the current price point if these went mainstream.  My guess is the price would creep back into about 50% of what SparkFun sells the units, or half of $35 (Maple Mini (https://www.sparkfun.com/products/11280))  Of course, speculation is purely guesswork in this case.

For most Arduino users, I would point them to the DIP version of the 1284 to provide 10X the headroom on SRAM.  My experience with that chip is that the current core is amazingly good on 1.0.6 thanks to Jack and others who worked hard to merge several cores into one.  With the exception of FFT's and floating-point transcendentals, 20 MHz will probably serve most hobbyists well.  Moving up to 48MHz and 72MHz and dropping to 3.3V for the uC core complicates the newbie path with lots of things to think about... IMO.

Thanks for the feedback, I'll let you know what happens.

Ray

Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 24, 2014, 05:50 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)



<...>
Hmm.  Reading the Leaflabs page on their bootloader issues, it seems to me that they got overly ambitious about how they wanted things to work (compared to, say, Leonardo.  Which is kludgey and not perfect, but seems to work most of the time for most people.  (On Leonardo, the bootloader also implements a serial port and runs a serial bootloader protocol.  While the sketch itself runs a second version of the usb/serial code that does the auto-reset thing when you attempt to set an "unlikely" bitrate (1200bps)))
The whole "virtual drive" thing is cute, but unnecessary, and complicated by the rarity of devices that implement both CDC and Mass Storage USB profiles...

Alas, it's probably not worth spending a lot of time on this, given that Leaflabs has "moved on", and the official ARM arduinos (Due and Zero) are using different chips (and also could use work.)

West,

As I was saying to Bob in my last post, these little boards at 5 for $24 seem to be very good for the more advanced uC segment of Arduino.  I'm getting error free compiles, links, and downloads using both COM and DFU (Actually, COM just uses DTR to put the bootloader into DFU) and all of the examples supplied originally by Maple work.  There is a significant, IMO, hole in their SPI library and I have not tried I2C, but the whole wireish thing needs to be revisited.  That being said, I can see using an under $5 board running at 72MHz with the ARM M3 instruction set for those special FFT projects or even to drive some of the cheap RGB displays.

I'm having a better appreciation of the ARM family of products after spending time with the Cypress M0 implementation of the uC on the PSoC.  Fairly radical difference in architecture from the AVR but the documentation for ARM is huge.  Just like Cypress, Maple utilizes the RedHat newlib: NewLib (https://sourceware.org/newlib/)

With the effort expended by bobcousins, I think we are going to have a 1.5.7 core implementation for Maple Mini and a workable toolchain.  This is step 1, just like with the Atmega1284P-PU, once the core is mainstream and repeatable, folks get interested.  I'm running a Commodore 64 bios and 6502 instruction-set translator with a graphics GLCD on the 1284... pretty fun stuff for a rainy day.

Ray

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 24, 2014, 11:13 pm
Ray

Can you let us know if you try I2C.

As far as I could see, bobs repo didn't include the Wire or other libraries that are in the IDE.

I tried copying the libraries folder from GitHub libmaple, which seemed to be the newest location, as there appeared to be hardware and software I2C implementations, but I can't get it to compile at the moment as the libraries, which I put in the hardware mapleasp folder, reference wirish in the core and there seems to be a path issue with what <wirish.h> refers to, when used from the libraries folder.


On another note I have 2 maple min clones on order, as well as having these generic STM32 boards, so I will see if my clones work as soon as they arrive.

I also ordered
http://www.ebay.com.au/itm/ARM-Cortex-M3-STM32F103C8T6-STM32-Core-Board-Minimum-System-Development-Board-/301247607101?pt=AU_B_I_Electrical_Test_Equipment&hash=item4623c1b13d

So it will be interesting to see if these work with the same configs.

However they've still not arrived from the Chinese ebay supplier yet, I think I've been waiting at least 3 weeks, but a lot of this stuff seems to take ages to get from china to Australia possibly it gets sent my surface mail, I.e on a ship.

Title: Re: What's this I found on eBay?
Post by: westfw on Oct 25, 2014, 08:14 am
I have heard elsewhere that I2C on the ST parts is "complicated."
http://www.eevblog.com/forum/microcontrollers/stm32-ghetto-style/msg529692/#msg529692
(of course, it's all MUCH different than an AVR.)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 25, 2014, 10:29 am
@westfm

yes. I've read that IC2 may even have issues in the silicon on some older (and perhaps current) STM32's

The guys on the leaflabs forum do seem to have done quite a lot of work and I know some Maple users use I2C, but at the moment I've had no luck using and of the Leaflabs guy's code :-(
Title: STM's CPAL peripheral library
Post by: rogerClark on Oct 26, 2014, 12:05 pm
Doing some research about I2C and SPI etc on the STM32 I have found that STM have a peripheral library (code), but looking at their license, it can only be directly used by end users, and it doesn't look like the license would allow it to be incorporated and re-distributed.

But I guess it would be possible to write code to use the library and people would have to download it themselves in order to it.

e.g. Like Audacity does with the  LAME encoder.


I've not had any time at the weekend to do much towards getting I2C working, but I did manage to get the Wire library from Libmaple to compile, but only by putting in hardcoded paths in files like wire.h and hardware.h etc, to both files in the lib folder and also to core stuff like wirish.h

(If someone could tell if if there is a way around this, I'd love to know what it is).
e.g.
I have added the Wire library in
hardware\maple-asp\Maple\libraries\Wire.

But it doesn't compile unless I change the #includes to be paths like this

Code: [Select]
#include "C:\Users\myusername\Documents\Arduino\hardware\maple-asp\Maple\libraries\Wire\Wire.h"





However even thought it compiled, the basic test program I'm using (the I2CScanner from the Arduino playground) doesn't work, it reports I2C devices at every address :-(

I think the only way to work out whats going on is to put debug statements (serial.print etc) all the way down to the lowest levels of the I2C, to see quite what its doing.

Last time I looked with my scope, the I2C lines were not being driven with any data at all, so either I"m using the wrong pins, or there is something else wrong.

I'm using PB6 and PB7 which I thought were the I2C pins for the hardware I2C channel 1.
I"ll need to double check

But work has taken up over half my weekend, so that was out of the question
Title: Re: What's this I found on eBay?
Post by: smeezekitty on Oct 26, 2014, 11:32 pm
Or you could reverse engineer the library
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 27, 2014, 11:37 am
@smeezekitty

I think you mean re-write it to remove the license restrictions

Yes. I don't see why not.

They give away the source code, but basically say you can't redistribute it, you can only use it in your own code for your own products.



Re: My ongoing quest to get I2C working

Well, I've now realised that LeafLabs implementation of Wire is totally incompatible with any code that uses the normal Arduino Wire API calls.

e.g. The LeadLabs Wire library doesn't have the core functions of read() and write()   aarrgggghh

Their wire library has send() and receive() which I suspect are not quite the same otherwise I can't see why they would have given them different names


This means that I can't use any Arduino I2C libraries e.g. for the MPU9150 motion sensor without modifying the libraries like i2cdev which it uses.


I'm not entirely sure why Leaflabs would not have attempted to implement the same API that the AVR Arduino boards use.


So realistically, what actually needs to happen is for the LeafLabs I2C (Wire) library to be re-written.
which is a bit more than I had bargained for.



I'm not sure if the LeafLabs forums are active at all any more, or whether people on that forum are mostly here, but it would be interesting to know quite why Leaflabs decided to implement a no Ardiuno compatible Wire API.

BTW. The LeafLabs Wire API I'm using is from their github repo
https://github.com/leaflabs/libmaple/tree/master/libraries/Wire (the actual code for receive etc is in WireBase.cpp)

I have checked whats in their IDE package and as far as I can tell its the same

There may be other implementations of Wire for Maple and Maple Mini, I'll need to double check.

But so far its not looking very promising :-(


There are also some other strange things with the Wire API, endTransmission always does
    return SUCCESS;

which is different from the AVR Arduino lib

And... For some reason, LeafLabs chose to use I2C pins that were not the normal ones used on the STM32

i.e on the STM32 hardware I2C uses PB6 and PB7, but Leaflabs don't use these

The Leaflabs implementation is software I2C by bitbanging so they can use any pins they want, including PB6 and PB7 so I would have thought it would have made sense to build boards that used these pins so that planning for future releases they could use hardware API (as I2C hardware device 1 is on these pins)

I'm sure they had their reasons for doing this, but I've no idea what they would have been ;-)


Title: Re: What's this I found on eBay?
Post by: westfw on Oct 27, 2014, 04:59 pm
Quote
The LeafLabs Wire library doesn't have the core functions of read() and write()   aarrgggghh
Presumably it has send() and receive() like the wire library from 0022?  You might want to look at how much actual difference there is in the avr code before giving up (some of it just seems like method re-naming.)

My impression from the non-arduino complaints about the ST I2C implementation is that their standard peripheral library isn't going to help all that much :-(

You can always try bit-banging ...
Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 27, 2014, 08:36 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


I think that might be because I didn't check in the .exe to github! (.gitignore problem). The latest revision should be ok.

well, bobcousins, it was I who had screwed-up... long ago on Windows 7.  I split my drive into two partitions, C: and D: and moved Documents to D:  The script file
D:\Documents\Arduino\hardware\maple-asp\tools\win\maple_upload.bat
needed a little editing.

Now I can compile and upload in 1.5.7 IDE.
Code: [Select]
Sketch uses 10,660 bytes (9%) of program storage space. Maximum is 108,000 bytes.
D:\Documents\Arduino\hardware\maple-asp/tools/win/maple_upload.bat COM12 1 1EAF:0003 C:\Users\owner\AppData\Local\Temp\build1827699629228151412.tmp/FadingOnboard.cpp.bin
maple_loader v0.1
Resetting to bootloader via DTR pulse
Searching for DFU device [1EAF:0003]...
Found it!

Opening USB Device 0x1eaf:0x0003...
Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=1, name="DFU Program FLASH 0x08005000"
Setting Configuration 1...
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
bytes_per_hash=281
Starting download: [##################################################] finished!
error resetting after download: usb_reset: could not reset device, win error: The system cannot find the file specified.


state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode


Thank you.

Perhaps later in the week I will try SPI and I2C.  Up on the mbed site, there is an implementations of ILI9341 with the STMF103 but I have not found a graphic lib specifically for the Maple Mini.  I think the interest in the MM never peaked sufficiently to create critical mass for their user libraries.

Ray


PS: based upon this success I have ordered 5x for $24... just in case I like them enough to do a few projects.  t'aint nothing worst than to have one module of a uC and decide to create a permanent project!
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 27, 2014, 09:18 pm
@westfm

Thanks. I wasn't aware of the changes between Arduino 0022 and the current version.

After I posted, last night my time, I did think that perhaps just renaming the functions may be worth a try, but I've it had chance to give that a go.

The issue with endTransmission always returning SUCCESS could I suppose also be the 0022 API thing.


I presume that there must be a guide to porting 0022 Arduino sketches that use Wire to the newer API?
I guess I better get googling

@mrbrunette

I always order at least 2 of anything like this. Assuming its not expensive. Mainly in case I physically damage one of them due to electrical connections.

After finding that the 2 generic board I have, are not fully Maple mini clones, I have ordered 2 clones, so I will have 4 in total.

We're the 5 for $24, maple mini clones, or the generic stm32 board? Can you post a link?


BTW. Will hooked up an oscilloscope to the i2c lines, and the bit banged implementation is basically giving around a 10mhz clock signal.

Digital write to set the clock pin high is taking around 2.5 micro seconds, and another 2.5 to take the pin low.

So at 72mhz, this is probably 2 cycles for a digital write.

I'm not sure how fast the I2c is on the atmega series at 16mhz.


Anyway, my next steps will be to attempt to just to rename the wire functions and see if anything else needs to be changed.

Optimally, I guess that using hardware I2C would be the way to go, but I suspect I won't have time to look at that for a while.


Title: Re: What's this I found on eBay?
Post by: PaulRB on Oct 27, 2014, 10:05 pm
I have an I2C sketch running on my Maple Mini clone. Hooked up a ds3231 rtc, with 4K7 pullups on sda/scl, although it seems to work ok without them (suspect my ds3231 module has them built-in).

Code: [Select]
#include <Wire.h>

//RTC Data
#define RTCadrs 0x68
#define RTCrequestTime 0x00
#define RTCrequestTemp 0x11
#define RTCsetControl 0x0E

void setup() {
  Wire.begin();
}

void loop() {
 
  char buff[80];
  byte RTCsecs,RTCmins,RTChours;

  //get current date & time from RTC
  Wire.beginTransmission(RTCadrs);
  Wire.send(byte(RTCrequestTime));
  Wire.endTransmission();
  Wire.requestFrom(RTCadrs, 3);
  RTCsecs = Wire.receive();
  RTCmins = Wire.receive();
  RTChours = Wire.receive();

  SerialUSB.print(RTChours, HEX);
  SerialUSB.print(":");
  SerialUSB.print(RTCmins, HEX);
  SerialUSB.print(":");
  SerialUSB.println(RTCsecs, HEX);
 
  delay(1000);
   
}



I did make a change to the file Wire.h:

Code: [Select]

#define SDA 15
#define SCL 16


So the suspicion is that this is a bit-bang software i2c?
Title: Re: What's this I found on eBay?
Post by: westfw on Oct 27, 2014, 10:55 pm
Quote
and the bit banged implementation is basically giving around a 10mhz clock signal.
Really?  That's MUCH faster than I2C is supposed to run.  While SPI is pretty much a "bash the clock as fast as you can" sort of protocol, I2C is defined to operate at specific maximum clock rates - 100kHz for normal mode, and 400kHz for "fast" mode.)  The AVR library sets up 100kHz transmission...
Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 27, 2014, 11:45 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
@mrbrunette

I always order at least 2 of anything like this. Assuming its not expensive. Mainly in case I physically damage one of them due to electrical connections.
5PCS-LOT-leaflabs-Leaf-maple-mini-ARM-STM32 (http://www.aliexpress.com/item/5PCS-LOT-leaflabs-Leaf-maple-mini-ARM-STM32-compatibility/1758679593.html)


Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 27, 2014, 11:48 pm
@Westfm


Quote
Really?  That's MUCH faster than I2C is supposed to run.
I've attached a screengrab from my scope, taken last night (my time) while was testing the I2C scanner sketch


Blue trace is the clock, ignore the overshoot, its because I didn't ground that probe, also ignore the relative voltages, I moved the traces apart so I could see what was going on.


Anyway.

I've just done a search and replace in Wire.cpp and Wire.h and changed send( for write( and receive( for read, and after I figured out I'd got my SCL and SDA wires around the wrong way

It seems to be working fine, reading a BMP085 barometer module that I was using for my basic I2C testing.

I'll need to put the scope on the lines again to see whats actually happening reading real data, but I can't see its going to behave any different.

The code just does digitalWrite(pin,HIGH); followed by digitalWrite(pin,LOW), to toggle the clock line,  there are no "nops" etc to slow it down, so at 72Mhz its doing what I would expect.

But perhaps I'm not looking at this correctly !

@paulRB

Can you do some timing tests e.f. use microseconds() to see how long it takes to do for example 1000 read's of the time ?

and confirm how fast its going?



Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 27, 2014, 11:50 pm
Ray

Thanks for the link.

I can see they are real Maple Mini clones, and not the generic version I have.

I think its better for people to get those, than the generics, as they have the transistors to allow the processor to force USB re-enumeration
Title: Re: What's this I found on eBay?
Post by: westfw on Oct 28, 2014, 02:28 am
Quote
But perhaps I'm not looking at this correctly !
I had in mind "maybe it wasn't written correctly, which is another reason so many people have had problems with it."
Whether 'very fast' I2C would work would be highly dependent on the slave devices implementation.  If they have one big hardware shift register, there probably wouldn't be a problem.  If they're actually microcontrollers shifting in one byte (or less) at a time and doing stuff in SW, there could easily be problems.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 28, 2014, 04:04 am
Hi @westfm


I agree. It would be really flakey if its really running at the speeds I think it is.

Can you look at the PNG of my scope trace, it seriously looks like its clocking at just under 10Mhz


Horizontal scale on my scope trace is 20 micro seconds per division, so its clocking 2 cycles in around 20 micros,  I think its just a bit under  10Mhz

Anything with long leads is going to have serious issues at that speed let alone if the other end is a slow running microprocessor

As the board speed is defined in the boards config, I presume that perhaps some #defines can be used to insert a load of assembly "nops" in order to slow this down.


Its something I can take a look at tonight (2pm here now) - but I'm swamped with work for my day job, so will need to try to add in asm("nop") if there is such a think in STM32 language ??


Title: Re: What's this I found on eBay?
Post by: westfw on Oct 28, 2014, 06:45 am
Quote
Horizontal scale on my scope trace is 20 micro seconds per division, so its clocking 2 cycles in around 20 micros,  I think its just a bit under  10Mhz
Oops.  Your math is suspect.  2 cycles in 20us is about 100kHz  (2 cycles in 2us would be 1MHz, right?)
Which is about what it should be.  Are you sure that there are no delays in there somehow?  digitalWrite() is pretty slow, but I thought it was faster than that...

Title: Re: What's this I found on eBay?
Post by: westfw on Oct 28, 2014, 07:35 am
Quote
try to add in asm("nop") if there is such a think in STM32 language ??
Yes, but the "nop" instruction on ARMs is not guaranteed to take any time.  :-)
It's actually pretty difficult to get accurate small delays on ARMs (though I guess they're repeatable once you get them.)  (On the other hand, the 5us delay you need to generate a 100kHz clock isn't particularly "short" compared to a 72MHz chip...)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 28, 2014, 09:45 am
Sorry @westFM

My maths was totally wrong, its only running at 73khz (brain fade)


However, as this value seemed strange i.e not 100khz I looked in Wire.h to see how the speed is controlled and there is a #defined that does assemble some nops

Code: [Select]
#define I2C_DELAY(x) do{for(int i=0;i<x;i++) {asm volatile("nop");}}while(0)


Looking at the value of delay that is used (25), I can only get this to give 100khz if I change the code so that the delay macro is called without any arguements and the value of delay is taken directly from the #defined for SOFT_STANDARD

So it looks the version of gcc that the MapleIDE used is giving different timings to the version of gcc that is packaged with Arduino 1.0.5  (or there is some other difference e.g. in the flags etc - but I cant see any difference looking at the platform.txt files of both bob's file and the maple ide file)


Anyone using bob's hardware files, with Arduino should probably change the #defined in Wire.h to

#define SOFT_STANDARD 16
#define SOFT_FAST 0

and even then SOFT_FAST is only around 250khz, not 400 as per the I2C spec.

But this may be adequate for most people.

I suspect to get higher speeds, it would probably be better of using STM's CPAL libs and use hardware I2C




Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 28, 2014, 09:03 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Just an FYI:
It appears that some work was previously published on SPI + DMA:
SMT32 Maple SPI + DMA (http://polplaiconesa.com/tutorials/SPI+DMA.html)

I have not read the entire article, but I did a quick scan and the author is claiming:
Quote
I just tested and I am getting 1700KB/s approx.
... more ... (http://forums.leaflabs.com/topic.php?id=112&page=5#post-6674)

I'm having a bit of trouble understanding how to "add" user libraries to the Arduino 1.5.7 GUI that are specific to a processor... that is, restated, how to separate them from the user's Documents\Arduino\libraries directory?  I really need to read the 1.5.x stuff.


Ray
Title: Re: What's this I found on eBay?
Post by: hobby16 on Oct 29, 2014, 12:28 pm
Hi all,
thank you for the thread, I have learned a lot.
Sometimes, it's was hard to follow without the board's schematics.
So I draw it, see attachment.
I hope there is no error, if any is spotted, please let me know.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 29, 2014, 12:37 pm
Ray

I added the libraries from the maple IDE zip to bobs mapleasp stuff, I.e I had to add the library folder, and fix some path issues

However I agree there are problems with other libraries which would need conditional compilation for different platforms, mainly progmem seems to be the problem I see a lot.

I posted to the Due forum to see if anyone had already thought of a good solution to this, but last time I looked, there were no replies.

But in another thread I spoke to Nick and there is a way to list the defines, and I've taken a quick look at the defines for an ARM build, but could not see anything as an obvious candidate for conditional compile.
The thread is in the programming forum, and is to do with setup of boards, as I hijacked an old thread that seemed relevant.


I will need to run the compiler again with the -dM -E.  switches to look at the output from an AVR device build.

Surely however this problem must have cropped up before with the Due and the Yun
Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 29, 2014, 02:12 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
Surely however this problem must have cropped up before with the Due and the Yun
It was my understanding that supported products, regardless of AVR/ARM toolchain, would be in the primary installation directory, for Windows:

\Program Files\arduino156r2\hardware\

then subdirectories from that point would be constructed for product.  That is:

...\<description>\<technology>\cores\
...\<description>\<technology>\bootloaders\
...\<description>\<technology>\variants\

Example:
...\tiny\avr\boards.txt, platform.txt, programmers.txt

This is how I have my Win8.1 Professional 64-bit environment set up and it appears to work correctly in the 1.5.x environment.

My 1284 directory appears as:

\Program Files\arduino156r2\hardware\mighty-1284p\avr\cores\standard
\Program Files\arduino156r2\hardware\mighty-1284p\avr\bootloaders\optiboot
\Program Files\arduino156r2\hardware\mighty-1284p\avr\bootloaders\standard
\Program Files\arduino156r2\hardware\mighty-1284p\avr\variants\bobuino
\Program Files\arduino156r2\hardware\mighty-1284p\avr\variants\avr_developers


So, sticking the STM32 stuff off into the user directory was not what I had expected... although it works... kinda.  Right now, my issue is:
#include <library> is searched from the Arduino libraries: \Program Files\arduino156r2\libraries
and
#include "library" seems to require a full path for each entry.  The problem is that another .H file has a relative path, the path link breaks such that the subordinate .H must also be edited.  Clearly, something is wrong.  There must be an easy way to encapsulate the ARM libraries from the AVR ones.


Ray

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 29, 2014, 08:44 pm
Ray,

Re library paths in #include ...

I initially had issues with the Wire library which I copied into the maple-asp hardware folder, as it used statements like

#include <Wire/Wire.h>

From Wire.cpp

But Wire.h was not being found.

I eventually found that for libraries/wire/wire.cpp to access
 libraries/wire/wire.h

ie files in the same folder as each other.

I changed the includes to

#include "wire.h"

And it then compiled ok.


If that fails, the hacky solution is to put the full windows path to the file that needs to be included, in double quotes

E.g.

#include "c:/users/yourusername/somefolder/somefile.h"

This is what I initially did to get wire working, but I have since tidied it up.



My remaining issue however, is that I have user libraries for lots of hardware, which won't compile for ARM because progmem.h doesn't exist more do any of its functions.

As I will still use the AVR arduinos a lot, I need a way to build all user libraries for both AVR and ARM.


One way around the progmem files issue is to create some files with equivalent functions.
But it seems odd that no one using the due has not encountered and solved this issue already.


I have been tidying up my build process, where I use a USB to serial adaptor and don't use a bootloader.

When I have it a bit more organised, I think it will put my whole maple asp hierarchy of files, that BobC initially created, into a public GitHub repo in case its of any benefit to the community
I.e I can upload via USB to serial straight from the IDE, however I do need to press the reset button on the stm32 button first to get it to enter its hardware serial upload mode

Title: Re: What's this I found on eBay?
Post by: westfw on Oct 29, 2014, 10:53 pm
Quote
One way around the progmem files issue is to create some files with equivalent functions.
But it seems odd that no one using the due has not encountered and solved this issue already.
ARM doesn't need the complications of the the AVR pgmspace constructs.  I thought Due/etc got around this with a set of null definitions...   Ah, there they are, off in:
.../hardware/arduino/sam/cores/arduino/avr/pgmspace.h



Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 12:08 am
@westfm

Quote
I thought Due/etc got around this with a set of null definitions...   Ah, there they are, off in:
.../hardware/arduino/sam/cores/arduino/avr/pgmspace.h
That's basically what I was proposing for the Maple stuff, I just wasn't aware of how the Due did it

I will try copying the relevant due files into the maple-asp hierarchy and see if it compiles.
Title: Re: What's this I found on eBay?
Post by: hobby16 on Oct 30, 2014, 12:56 am
When I have it a bit more organised, I think it will put my whole maple asp hierarchy of files, that BobC initially created, into a public GitHub repo in case its of any benefit to the community
I.e I can upload via USB to serial straight from the IDE, however I do need to press the reset button on the stm32 button first to get it to enter its hardware serial upload mode
Hi, Roger,
I'm sure interested in such GitHub repo and I'm eager to have it. The serial bootloading with reset button is fine, I've succeded to use it with st-flashloader so I like it.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 01:01 am
Hi hobby16

OK

No problem

I was hoping to tidy a few things up, but its not that bad.

I already have an arduino pro on my github account, so I'll add it to that rep and post when its finished uploading.

I'm using a command line stm32flash exe thing I found on the web (which is open source, but I couldnt get it to compile as I didnt have some of the libs it needed. However I found a precompiled version that someone had done and it worked for me

I'll get back to you shortly when its uploaded

Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 30, 2014, 01:43 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
If that fails, the hacky solution is to put the full windows path to the file that needs to be included, in double quotes...
E.g.

#include "c:/users/yourusername/somefolder/somefile.h"
That is where I am now, but I do not like the solution.  Most cross-platform libs will use #IF #ENDIF to deal with architectural issues.  IMO: placing OS centric and user-centric paths in libs is a BIG noNO.  I'll do it only to quickly hack a compile, but Arduino GUI 1.5.x is handling AVR and ARM so there is a right way, I just have not seen the Doc describing the library stuff.  Guess I need to go looking...

I have 1.5.7 downloading to the Maple mini from the GUI w/o having to force DFU.  I had to use device manager in Win8.1 to delete the USB enumeration and it reinstalled upon replugging the mini.... I then pointed it to the 32-bit unsigned driver while Win8.1 was in Test Mode.  Now, the COM port enumerates and the DTR on download flips to DFU.

Ray

Title: Modified version of bobc's work
Post by: rogerClark on Oct 30, 2014, 01:55 am
OK.

Not wanting to tread on bobc's toes...

But I've upload my version of bob's maple-asp to my git repo

https://github.com/rogerclarkmelbourne/Arduino_STM32

If you put the Arduino_STM32 in Arduino/hardware

then reload the 1.5.x IDE, you will see the new boards listed


The existing Maple boards are at the top of the new list, and the generic STM32 board I added is at the bottom.

The generic board doesn't use the Maple boot loader etc, it uploads via USB to serial, into the start of flash memory at 0x8000000 and then runs the code from that address

I'll need to write some docs on how to do this, but basically,

The STM32 board needs to be put into its serial upload mode, which is done my pulling pin boot0 high and then resetting. Once its in this mode it seems to stay in it definitively but there may be a time out.

On my generic STM32 board, it has 2 jump links one for boot0 and one for boot1.

I leave boot0 in the HIGH position all the time when developing.

Then when I'm ready to upload. I press reset, then press the Upload button in the IDE, which causes the IDE to compile and then call the stm32flash.exe program which uploads to the com port selected in the IDE.

Note. I didn't compile the stm32flash exe, I downloaded it from someone else's site, but it is open source, so I will grab those sources and put them into my git repo.

For non windows users, there is a python stm uploader, but I've not managed to get it to work.
However I recently made some changes to the linker flash addresses etc and other board definition files, and I suspect it will now work, if any linux or mac users want to give it a go.

I'll also dig the python sources out and add them when I get chance.


Changes between Bob's original files and my new files are mainly the board definition stuff, plus the stm32 upload stuff, but I also added the libraries from the LeafLabs IDE
However.. I have only got Wire working, I have not tested the SPI stuff, and I suspect it won't even compile without some minor changes

With the wire stuff, I've got it to compile by fixing the include paths, but I've also looked at the transfer speed and it was a bit low 73khz instead of 100khz for standard transfer rate.
So I've fixed this by changing the delay code.
Wire fast mode will not run at 400khz with the existing code, there are too many function calls, costing a lot of time, which cause the bit banged implementation to only operate at around 260khz

But as I've previously posted, I don't think its worth optimizing it, when the STM32 has hardware DMA based I2C which could be used and which allows very fast transfers and effectively some parallel processing.


Anyway. Let me know if it works for anyone else, and I'm happy to update the code, or of course feel free to completely copy it and post it elsewhere which is what I've done with bobc's files, which is what he's done with Leaflabs code ;-)
PS. I guess I better add a license to reflect the original license, but I'll get to that later



Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 02:13 am
Hi Ray,

I totally agree.

User centric paths are a definite no-no...

Looking at the Due thread, people seem to be writing Due ports of the common libraries, rather than attempting cross-platform versions.

I can understand why people would want to do this, because (a) its easier to do and (b) sometimes the scope of the changes are large and would require big sections of the code ifdef'ed in and out.

Perhaps the ultimate solution is to have sub folders under the Arduino/libraries folder

one per architecture

e.g. libraries/avr/
libraries/sam
libraries/cortex-m3

Note. I think the Maple stuff would need to be called cortex-m3 as its the gcc name for this

I wonder how hard it would be to change this in the IDE, possibly not that hard.





Title: Re: What's this I found on eBay?
Post by: westfw on Oct 30, 2014, 03:17 am
Quote
I think the Maple stuff would need to be called cortex-m3 as its the gcc name for this
That depends.  Peripherals vary greatly between different ARM chips from different vendors (or even from the same vendor), so putting a DMA-based I2C driver for STM32F103 (maple) in a "cortex-m3" directory would be a big mistake.   OTOH, generic optimized algorithms for a 32bit ARM, or libraries built on top of the arduino core functions could go there.
Title: STM32 memcpy missing ?
Post by: rogerClark on Oct 30, 2014, 03:33 am
Hi Guys,

Does anyone know why memcpy is not implemented as part of maple implementation (well at least not the files I have ...)

Can someone try putting memcpy in some code, even in blink and see if it compiles for them.

I get a message straight away saying its not defined.


Does anyone know why this may be happening ?

Note. The Due seems to have memcpy, and it uses the same compilor, so there must be something else that different in the hardware stuff for the due and the STM32
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 03:45 am
@westfw


OK. I'll need to do some more research about why people are posting Due specific libraries to the forum.

I thought perhaps some thing like progmem were the reason that Due needed specific libraries for some things, but as these are re-defined in the avr folder (which you previously sent).

The differences must be other stuff, e.g. attach interrupt perhaps ?


Either way, I don't have an issue with  having

arduino/libraries/avr
arduino/libraries/sam
arduino/libraries/stm32F1xx

If this is the way to do it.

Its not too much of an overhead for a normal avr (only) user to go into libraries/avr and put their avr libraries in there !

and the rest of us who dabble in the more exotic processors should be capable of making new folders ;-)
Title: Re: What's this I found on eBay?
Post by: westfw on Oct 30, 2014, 06:32 am
Quote
why memcpy is not implemented
memcpy() is part of libc, which is typically NOT considered part of the compiler for deeply embedded system.  (for avr, you get avr-libc, and there are numerous "generic" libc implementations for various other chips with various licenses.   Typically this is one of the things you get from a compiler "vendor" (including a chip company) even when they are using gcc for the actual compiler.  And there are usually license restrictions on using their library code on other vendors cpys.  There are also open source versions of libc, including "newlib" (which is "big"), "newlib nano" (smaller, for more deeply embedded apps), and ... I dunno.

It looks like Due is using newlib nano from .../hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/arm-none-eabi/lib (there's a "nano.specs" there.)  It's unclear whether this is Atmel-specific or licensed., or how much trouble you would get in for using atmel libc on an ST microcontroller.  (I'm not even sure which library is used, among the 4 or 5 different arm libraries that are in there...)

Are you re-using the avr arm compiler, or do you still have the toolset (somehow?) download the arm compiler from somewhere else?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 07:31 am

Thanks. @westfm

I'm just using the ARM compilor that comes with 1.5.x

Looking at this page

http://community.arm.com/groups/embedded/blog/2013/01/21/shrink-your-mcu-code-size-with-gcc-arm-embedded-47

It mentions open source a lot and newlib-nano, but I've not specifically seen a license


I will need to take a look at the Due linking stuff etc, so we how nano has been integrated and why its not being called in by the Maple installation (it probably wasn't available when LeafLabs originally did their dev work, but I'll also check their IDE installtion to see if it was there)

I'll post back when I find out or make any progress, as this sort of lib seems quite fundamental to allowing a lot of other libraries to compile, and I often use memcpy in my code e.f. to copy arrays and buffers.

Anyway, Thanks again

Roger
Title: Re: What's this I found on eBay?
Post by: westfw on Oct 30, 2014, 09:13 am
It's possible that the Maple stuff does not include a libc.  After all, the arduino documentation doesn't explicitly mention most of the libc functions, and they may not be explicitly necessary to support Arduino sketches.  (although most of us expect those functions to be present.)

You might look at some of the ChipKit (PIC32) forum archives.  They counted their conversion from Microchip libc libraries (which have odd license requirements) to newlib as a pretty significant accomplishment.

Hmm.  Downloading the (old) MapleIDE, I find a libc in hardware/tools/arm/arm-none-eabi/lib
I can't tell where it's from, though.  I do see memcpy() in there, but I need to #include <string.h> for a sketch to find it.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 10:14 am
@westfm

I've been looking through the compiler intermediate output, and it looks like stdlib.h was not included from wirish.h (which is included from Arduino.h)

ie Due includes

#include <stdlib.h>
#include <string.h>
#include <math.h>

and some others that wirish,h doesn't

However, just adding in <stdlib.h> gives errors because the macro _EXFUN which is used in the prototyping of memcpy and other functions.

i.e I get this error

Code: [Select]
c:\program files (x86)\arduino\hardware\tools\gcc-arm-none-eabi-4.8.3-2014q1\arm-none-eabi\include\stdlib.h:67:5: error: expected unqualified-id before 'int'
 int _EXFUN(abs,(int));



It appears that _EXFUN is defined in

Arduino\hardware\tools\gcc-arm-none-eabi-4.8.3-2014q1\arm-none-eabi\include

But just including _ansi.h  doesn't seem to fix it either, and its quite possible that _ansi.h is already included already at this point.

and in reality there is something else that needs to be included before this, which has not been included ;-(

Or possibly one of the gcc -DDefines that the Due uses

I have tried just putting the _EXFUN def's in wirish.h but that just gave other errors

So at the moment I'm at a loss to work out quite what needs to be defined or included in order that the stuff in stdlib actually compiles

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 10:39 am
Update.


I found this on the LeafLabs site

http://leaflabs.com/docs/faq.html

Which gave me a bit of an idea of how to fix this, and I tried including <strlib.h> into my test sketch but it didn't fix it.
However I noticed in the Due's Arduino.h, that it also included <string.h> which I think is where the memcpy functions are also declared.
So I included that as well, and it worked.

So I tried moving these includes into wirish.h under <stdint.h> but it didnt work.

However I found that if I included the files at the top of wirish.h it did compile fine.

So I've now included the files that the Due includes in the top of Arduino.h into the top of wirish.h.


Doing this, doesn't seem to cause any problems. My I2C test sketch connecting to a barometer module still works fine.

I guess that compiles may be slightly slower

I've pushed the changes to my github repo


Note. I think I seriously confused Github, because the clock on my PC went to the wrong timezone after I booted back from Linux into Windows.

So the commits look like they are out of order.

I'm thinking of actually doing the whole git repo thing again

By putting bobs code into the repo first, then replacing it with my changed code so that we get tracked changed from the beginning, but at the moment I'm just going to leave it, as I have better things to waste my time on ;-)

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 11:31 am
Update.

I needed EEPROM lib for one of the libraries I want to use (RTIMULib), so I found this library and have added it to the other Maple libs.

HACK ALERT. I don't know what EEPROM page size is required for the Maple. I have just put in a define for the MCU_STM32F103RB to get it to compile

The EEPROM_PAGE_SIZE and EEPROM_START_ADDRESS all need to be changed to work with the Maple or Maple Mini or Generic STM32 boards.

However the only reference I can find is this application note from ST
http://www.st.com/web/en/resource/technical/document/application_note/CD00165693.pdf

and it doesn't make any mention of device variations.

STM also have a file (suite) which includes an EEPROM_Emulation/src/eeprom.c  however I'm not sure where it can be downloaded from.
It may require login and is probably under their non-distributable license anyway, but it may give a hint about memory pages etc


BTW. I now need to get I2CDev to compile - which is currently not doing



BTW. Apologies for the various mistakes while checking stuff into the git repo.. Its been a long day ;-)
Title: Re: What's this I found on eBay?
Post by: hobby16 on Oct 30, 2014, 02:13 pm
I already have an arduino pro on my github account, so I'll add it to that rep and post when its finished uploading.
Thank you Roger, that's awesome ! I'll have spare time this week-end to check all this out to have the led flashing ;) Hope you saw the schematics I made for the board.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 30, 2014, 04:33 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


To follow-up on #118 re: library architecture, the answer was easy to find but may be more difficult to implement: Arduino-IDE-1.5:-Library-specification (https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification)
Summary:
Quote
In 1.5.x, libraries placed in the user's sketchbook folder (in the libraries/ sub-folder) will be made available for all boards, which may include multiple different processor architectures. To provide architecture-specific code or optimizations, library authors can use the ARDUINO_ARCH_XXX preprocessor macro (#define), where XXX is the name of the architecture (as determined by the name of the folder containing it), e.g. ARDUINO_ARCH_AVR will be defined when compiling for AVR-based boards. For example,

#if defined(ARDUINO_ARCH_AVR)
  // AVR-specific code
#elif defined(ARDUINO_ARCH_SAM)
  // SAM-specific code
#else
  // generic, non-platform specific code
#endif
Alternatively, if a library only works on certain architectures, you can provide an explicit error message (instead of allowing the compilation to fail in an difficult to understand way):

#if defined(ARDUINO_ARCH_AVR)
  // AVR-specific code
#elif defined(ARDUINO_ARCH_SAM)
  // SAM-specific code
#else
  #error "This library only supports boards with an AVR or SAM processor."
#endif
rogerClark:
I pulled a ZIP from you Github and overlayed what I already had... using the 1.5.7 GUI, nothing broke which is to say, I can compile without error blinky, point to the COMxx port for the Mini, and have the COMxx DTR force a DFU and the batch file, maple_upload.bat does execute and load the compiled binary.

So, users pulling your Github ZIP should be able to compile programs not dependent on Arduino lib support and upload the the Maple Mini utilizing a virtual comm port and DFU using Arduino GUI 1.5.7.
Users should unZIP the archive from Github into their Arduino home directory which will be similar to:
\Documents\Arduino\hardware\maple-asp
Note:maple-asp is the original name but roger's ZIP defaults to: Arduino_STM32-master

Roger, I'm thinking a name more specific to the board-type should be utilize as the folder name subordinate to \hardware\ but maybe with more intelligence than maple-asp?  Maybe, "maplemini_ARM" or something... I'm not hung up on this as I'm using the maple-asp directory name myself.

I'm going to look into the library thing a bit more and attempt to implement an example.

PROGMEM:
Here is an answer from leaflabs
PROGMEM (http://leaflabs.com/docs/arm-gcc.html#arm-gcc-attribute-flash)
Quote
Replacing PROGMEM: If you need to store a lot of constant data, you can store variables in Flash (instead of RAM) by using the libmaple macro __FLASH__. Here's an example:

uint32 array[] __FLASH__ = {0, 1, 2};
This will help you save RAM when you need to store large amounts of data, like look-up tables.

You can only store values which are compile-time constants (like numbers and strings, and arrays of numbers and strings) in this way. Also, if you try to change a variable stored in Flash, your program will crash.

If you need to port over AVR/Arduino code that uses pgmspace.h, these declarations may help you:

typedef const unsigned char prog_uchar;
#define pgm_read_byte_near(x) (*(prog_uchar*)x)
#define pgm_read_byte(x) (*(prog_uchar*)x)
Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 08:45 pm
Hi Ray

I'm not hung up on the name. But I wanted to convey that its not just maple boards it supports, its also other generic stm32 boards.

Perhaps

Maple_STM32

Would be a better title.

I'm glad the maple stuff still works, as I wasn't able to test it, as my maple clones still have not arrived, nor has the other larger generic STM32 board, I.e more akin to a uno sized board

Re: progmem

I have not tested it, but I have copied the avr folder from the SAM core of  Arduino 1.5.x and added the includes for this into wirish.h

I have not had time to look in var/progmem but I think it provides macros and definitions to make progmem statements work on the due

However I have not had time to test whether this has resolved the progmem issue or just allowed the code to compile.


Just to reiterate, the EEPROM library I found and added, is also untested, and although it compiles I have not verified the correct flash page it should use, or the page size.
So currently the EEPROM code may possibly overwrite the program.


Re ARDRUINO_ARC_xxx

It should be easy to add this to the boards.txt etc

Perhaps @westfm is the best person to advise us on this question, he / she seems to be more of an ARM expert than I am ;-)

But at a minimum it would need to be

ARDRUINO_ARC_STM32

And possibly as stm do lots of variants, it may need to be


ARDRUINO_ARC_STM32F1XX

And even then... Looking at the code in EEPROM.h. Minor variations in the part number at the end, e.g. The bit like C6T at the end of the part number, possibly have an effect on what needs to go in the code.

However for the moment I will add a definition as



ARDRUINO_ARC_STM32F1XX

As its my best guess.



Also...

The guy who wrote the EEPROM library, also has a CAN bus library, so I think I will add it as untested code to my repo, so that at least all these things are kept in one place.


BTW. I noticed on the Due forum there is a thread of libraries ported to the Due, but they are not in one central location, ie some on people's github account, some on google code, some in blogs as code, some posted to the forum as code etc etc.

I'm surprised someone has not setup a git repo and put them all in one place.


I may do this, and also do the same thing for any maple libs I find.



One other thing.

I'm not sure how long leaflabs will keep their wiki pages going, so I may find out if I can add their maple pages to my git repo

However I think they are copyright leaflabs so I will need to get permission.

Cheers

Roger


Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 08:53 pm
Hobby16

I'm not sure if you have a maple clone or a generic stm32 board.

Be aware that the generic stm32 boards seem to have their led on a different pin to the maple boards

I think my generic board has the led on pin PC13

On my generic board I soldered on another led to the same pin as on the maple mini.


Also.

As a general point. If you need to address the pins by their real names, and not the maple overlay of numbers. The original pins e..g PB0 etc are also defined in one of the headers, and personally, I think it may make more sense to do it that way.

Oh one other thing.

If you are using USB to serial, for debugging to the terminal, it works fine, but, its on serial1, so currently I'm using #define Serial Serial1 in the top of existing sketches so that I don't need to change all the code.

I may add this statement to boards.txt for the generic stm32 board
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 08:55 pm
Ray,

Sorry. I forgot...

I'm not sure why my boards.txt defaults to stm32, its the last one in the list.

Arduino must write something to one of the hardware files to store this.

I will check.

Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 30, 2014, 09:05 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


More info on 1.5.x

manpage 1.5.x (https://github.com/arduino/Arduino/blob/ide-1.5.x/build/shared/manpage.adoc)

Of interest:

--board package:arch:board[:parameters]

Quote
1.5.8
Introduced --save-prefs.

--pref options are now not saved to the preferences file, just like --board and --port, unless --save-prefs is specified.

A path passed to --preferences-file, or set in the build.path, preferences.path or settings.path is now interpreted relative to the current directory instead of the location of the arduino command itself.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 10:03 pm
Ray,

I just dumped the defines for the Due and the Maple and the Maple has this for its ARC

ARDUINO_ARCH_MAPLE

the Due has

ARDUINO_ARCH_SAM



I can't quite see where the MAPLE and SAM bit is being defined, so I've tried changing the name of the folder inside the hardware folder from maple to STM32F1XX and it changed the def to

ARDUINO_ARCH_STM32F1XX


Changing the folder name seemed to have no ill effects, the boards are still recognized in the menu and it compiles OK


Can I have a show of hands for the name of this, as its important in terms of this

ARDUINO_ARCH 

statement

Personally, I'd prefer the STM32F1XX as it fits with the SAM  which is Atmels line of devices,
where as Maple is effectively a brand name of leaflabs



Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 10:06 pm
Guys

As neither the PM's on the forum or the notifications are working for me.

Please feel free to email me with suggestions etc.  My email is my first name  (no not clark ;-)
and my domain name is rogerclark.net   (surprising huh!)

Cheers

Roger Clark
Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 30, 2014, 10:53 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
Personally, I'd prefer the STM32F1XX as it fits with the SAM 
+1

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 30, 2014, 11:19 pm
Ray

Thanks

I'll wait for a few more votes.

BTW.

If anyone wants to suggest a repo name, please let me know.

I already have an Arduino on my github account, but that has other stuff in it, and I think its best to keep this separate.


I guess it doesn't need to have Arduino in the title necessarily, but it does make it clear what its for.

Perhaps

Maple_STM32  would be an OK repo name.

Title: Re: What's this I found on eBay?
Post by: mrburnette on Oct 30, 2014, 11:32 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
If anyone wants to suggest a repo name, please let me know.
Down South in the U.S. "repo" is the man that comes at night for ya ride when ya miss a payment.  Most of their tow trucks are stenciled with "Bubba" "Billy" or "Buck"... Nothing over 5 characters cause no one wants to look at both hands for the knuckle tattoos when they have to spell their name quickly.

redneckbabynames (http://www.redneckbabynames.com/male-baby-names)


Seriously, for the naming convention just keep it simple and in-line with what Arduino has done in the way of precedence.


Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 31, 2014, 12:43 am
Quote
Most of their tow trucks are stenciled with "Bubba" "Billy" or "Buck"... Nothing over 5 characters cause no one wants to look at both hands for the knuckle tattoos when they have to spell their name quickly.
LOL

I guess I live too much in the Internet world where "repo" has the other meaning, ie repository ;-)

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 31, 2014, 10:42 am
I made a couple of updates to my git repository

1. Removed <math.h> from wirish.h because its included in wirish_math.h (from wirish.h)
2. Added -DSerial=Serial1  in the generic STM32 board definition, so that anyone using the serial uploader attached to Serial1 doesn't need to update their code and change Serial to Serial1

Note. For Maple mini users, it may be better if I define Serial to be SerialUSB but I don't know if it has precisely the same API


I also came across this port of Maple to the STM32F405 architecture, which has some interesting libraries, specifically I2CDev which I may be able to easily be able to port to STM32F1XX as I expect that a lot of the libraries are more of a general port to STM32 and Maple rather than the specific processor

I have briefly looked at I2CDev, and changed it a bit to get it to compile, but currently I just get loads of zero's instead of data :-(
However I am trying to use it with a different I2C device (MPU9150 so the problem may not actually be in the I2CDev lib)


Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 31, 2014, 11:07 am
http://code.google.com/p/libmaple-f405/
Title: Re: What's this I found on eBay?
Post by: mcnobby on Oct 31, 2014, 06:19 pm
Has anyone considered getting this device ported into the Arduino IDE ?
personally I am not bothered about bootloaders

Title: Re: What's this I found on eBay?
Post by: rogerClark on Oct 31, 2014, 09:59 pm
@mcnobby

Quote
Has anyone considered getting this device ported into the Arduino IDE ?
personally I am not bothered about bootloaders

I'm not too sure what you mean.

Do you mean include stm32 boards was part of the default IDE installation?

As these stm32 boards are not branded as Arduino I'm not sure how they could be included in the core IDE

Also, at the moment I suspect the current code has bugs, so is not really ready for mainstream users.
Title: Serial port names / numbers
Post by: rogerClark on Oct 31, 2014, 11:45 pm
Guys,

Anyone using my repository version...

I'm thinking of making a change so that the generic STM boards which dont work with the maple bootloader i,e where you upload into the start of flash and hence also don't have USB serial (at the moment).

Rather than redefining Serial1 to be Serial, the better fix for this is to change the code in HardwareSerial.h so that the serial ports are defined like they are in the Mega i. Serial then Serial1, Serial2 etc, rather than there not being a default Serial port.

Hence I'm going to change the code like this

i.e if BOOTLOADER_maple is defined (this is already set in boards.h) then the Serial ports start at Serial1, however for non-bootloader builds the Serial ports start at Serial, then Serial1 etc

See below

If anyone can see any issues with this please let me know

PS. For the Maple build, I'm not sure why they chose to use SerialUSB instead of Serial.

Can someone confirm, SerialUSB is what you need to use on the Maple mini to debug to the terminal

i.e In this case it may be worth just changing SerialUSB to Serial in the code, so that its more compatible with existing code


Code: [Select]


#ifdef BOOTLOADER_maple
#if BOARD_HAVE_USART1
extern HardwareSerial Serial1;
#endif
#if BOARD_HAVE_USART2
extern HardwareSerial Serial2;
#endif
#if BOARD_HAVE_USART3
extern HardwareSerial Serial3;
#endif
#if BOARD_HAVE_UART4
extern HardwareSerial Serial4;
#endif
#if BOARD_HAVE_UART5
extern HardwareSerial Serial5;
#endif
#if BOARD_HAVE_USART6
extern HardwareSerial Serial6;
#endif
#else
#if BOARD_HAVE_USART1
extern HardwareSerial Serial;
#endif
#if BOARD_HAVE_USART2
extern HardwareSerial Serial1;
#endif
#if BOARD_HAVE_USART3
extern HardwareSerial Serial2;
#endif
#if BOARD_HAVE_UART4
extern HardwareSerial Serial3;
#endif
#if BOARD_HAVE_UART5
extern HardwareSerial Serial4;
#endif
#if BOARD_HAVE_USART6
extern HardwareSerial Serial5;
#endif
#endif
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 01, 2014, 12:37 am
i have little experience with arm but this looks very interesting and has great potential considering the low cost of these boards. promini price but far more powerful.

highly recommend to put more effort into getting things like printf, spi. i2c, etc working and less into dealing with these bootloader sticky wickets. it looks like the chips come with a built-in bootloader and  hard to imagine not taking advantage of that.

imo putting a usb interface on a module is foolish since few applications use it and virtually all setups include an ftdi cable these days. maybe one of the reasons promini outsells uno, nano, leonardo, et al 10 to 1. it isnt the economy stupid, its the libraries. well actually it is the economy too. lol
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 01, 2014, 01:34 am
Quote
Has anyone considered getting this device ported into the Arduino IDE ?
I would think he meant setting up Maple as a board "extension" for the standard IDE (as has been done with 1284, tiny, teensy, and others), rather than having a separate "MapleIDE" tool.

But that's what you're already doing, right?
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 01, 2014, 02:11 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
But that's what you're already doing, right?
Yes,
bobcousins did a significant effort to build out a 1.5.x compatible structure and
rogerClark is working to have full-support for Maple under 1.5.7
Code up on: http://code.google.com/p/libmaple-f405/ (http://code.google.com/p/libmaple-f405/)


So far, I can compile to Maple Mini in 1.5.7 when pointed to "flash" ... The COMxx port DTR puts the Maple into DFU mode and flashes the chip.  Upon reboot, the serial becomes active over USB for the Arduino monitor. 

Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 02:50 am
@mcnobby and @westfm

Quote
I would think he meant setting up Maple as a board "extension" for the standard IDE (as has been done with 1284, tiny, teensy, and others), rather than having a separate "MapleIDE" tool.

But that's what you're already doing, right?
Yes.

Its done already.  BobC did it.



I've just taken BobC's work and added support for non-maple STM321XX boards and I'm trying to add things which are missing like I2C support (which is working OK in its basic form, using software "bit banging")

I've not tested SPI yet.

For those who have a generic STM32 board, rather than a true Maple or Maple mini clone, I've added a new board config which uploads via a USB to serial Adaptor to Serial 1 on the STM32 using the built in serial bootloader thats actually built into the STM32 chip's internal hardware

My version is very much a work in progress, but I think it is an improvement on Bobc's original work

See  https://github.com/rogerclarkmelbourne/Arduino_STM32

i.e copy the zip file into your Arduino/hardware folder (in My Documents on the PC).
Note, I"ve not looked at non-PC versions, thought I'm pretty sure that the generic STM32 via serial should work using a python uploader.

Looking around on the web, there are a lot of resources, e.g. fixes and libraries that the original Maple and Maple mini users created a few years ago, to work with the Maple IDE, which could be fairly easily ported to this Arduino IDE version.

E.g. I've found a CAN bus library, which is worth trying (at least to see if it can compile) - though I don't know if I have any CAN bus stuff to test it with .

Actually, thinking about it, I think I may have a CAN bus magnetometer from a quadcopter that I no longer use, that I may be able to use for testing CAN bus.


Re: USB
I took a look at this yesterday and there are good libraries from ST themselves for doing HID etc and I think possibly USB host on the usb port, but the license on these seems to vary.
Also I suspect it would be hard to integrate into the core.


BTW.

One major bug bear I have with the current Arduino API is the way SerialEvent is not really called when a serial char arrives, its just called after loop exits if there are any chars in the serial buffer

I"m tempted to add something new to the core, like InterruptSerialEvent  that is really called when a char arrives, as I have used external hardware which doesnt have much buffering and chars can be lost while waiting for loop to complete.

I can't see how this would be decremental to the core.


Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 02:56 am
@john1993

Do you mean add printf to Serial ?

I just tried using sprintf and it doesn't seem to be part of the Maple core.


However it is part of Arduino SAM (Due), so it should be possible to bring it across fairly easily as it doesn't do anything that's hardware specific.


Anyway, let me know if this is what you mean.

Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 01, 2014, 03:01 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
I just tried using sprintf and it doesn't seem to be part of the Maple core.
It's not part if newlib.  I have some code around from working with PSoC M0+ that is a lean sprintf and not a memory hog.  I will check it out in the Maple world someday soon... Have some commitments that is a high priority (for thee wife.)


Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 03:09 am
@mrbrunette

Quote
So far, I can compile to Maple Mini in 1.5.7 when pointed to "flash" ... The COMxx port DTR puts the Maple into DFU mode and flashes the chip.  Upon reboot, the serial becomes active over USB for the Arduino monitor.  

Ray
It would be possible to upload via Serial and then restart back into the Maple bootloader and hence you'd have the USB serial, assuming we get over the driver signing issues.

The problem is that most people now run a version of windows that requires device signing and the maple usb serial driver is not signed, hence its a pain to use.

I'm not sure if Maple implemented their own USB to serial protocol or just piggybacked on someone else's protocol.

This is a bit of a hack, but Maple just for example used FTDI's use protocol or another manufacturers, it would be quite simple to change the VID in the bootloader code (or even the HEX file) and then re-flash the bootloaer, and then use someone else's usb to serial driver.

Perhaps even Arduino's USB to serial driver e.g. that talks to LUFA on the Uno.

However, this sort of thing sounds like quite a lot of work in its own right, and would still not provide a clean upload process


One idea I had for this the other day, is to make a motherboard for the generic STM32 boards. A bit like these boards you can get for the Nano
(http://i.ebayimg.com/00/s/MTAwMVgxMDAx/z/9tQAAOSwnDZUJljH/$_57.JPG)

But they'd need to have an ATMega 32U4 etc like the uno does, which could then control the reset and uploading and serial comms via USB

I don't think it would be a huge amount of work to modify the 32U4 LUFA code to control the boot0 and reset pin on the STM32, but the more complex issue is the upload protocol.

Probably a modified version of one of the various opensource STM32flash loader progs could be built fairly easily that would toggle DTR or whatever was necessary to signal to the 32U4 that the STM32 needs to be rebooted into flash upload mode, then restarted in normal mode.

In this case, we still don't need necessarily to have a bootloader in the STM32 as it already has built in hardware to accept serial data.


Anyway... Food for thought.

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 03:15 am
It's not part if newlib.  I have some code around from working with PSoC M0+ that is a lean sprintf and not a memory hog.  I will check it out in the Maple world someday soon... Have some commitments that is a high priority (for thee wife.)


Ray
It looks like sprintf was part of the LeafLabs code

http://wiki.leaflabs.com/index.php?title=Accessing_the_Maple%27s_internal_temperature_sensor

But whats happening at the moment is I suspect is that the prototype if missing.


See

http://wiki.leaflabs.com/index.php?title=Accessing_the_Maple%27s_internal_temperature_sensor


Thats what was happening with memcpy.


I think I have now fixed memcpy, but I have to admit I've not tested memcpy yet (sorry)
But it does compile ;-)


I'll test memcpy now..
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 03:23 am
@westFM etc.

I wonder if it would be practical to build all the core files into a lib rather than having to link all the .o files each time there is a build. 

i.e it takes quite a long time to link it all, which seems pointless as most people will not be changing the core files in the hardware folder.


Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 03:25 am
Just test memcpy in the last version of the repo, and it seems to work OK, at least for a small text buffer

However my idea of remapping Serial1 as Serial doesnt work and seems to cause a crash.

I'm not sure why this is at the moment, and the best temporary solution is just for me to define Serial as Serial1 for a while.

However in the long term having Serial as the first serial port on the non-bootloader version is definitely the way to go
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 05:43 am
@mrbrunette (ray) and @john1993

Re: printf and sprintf

I found sprintf was not working because <stdio.h> was not being included in wirish.h

I added it and then tried a test, and it works.

In fact, it works better than on AVR, as this works

Code: [Select]
char buf1[64];
void setup() {
  // put your setup code here, to run once:
Serial1.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
sprintf(buf1,"Test %g",5.678);
Serial1.println(buf1);
delay(250);
}


and prints out "Test 5.678"  where on the AVR platform the sprintf function is a cut down version and doesn't support floating point types.

The functionality however comes at a price. The test program above, weighs in at
Quote
Sketch uses 29,748 bytes (27%) of program storage space. Maximum is 108,000 bytes.
But when I removed the sprintf line ..

Quote
Sketch uses 10,864 bytes (10%) of program storage space. Maximum is 108,000 bytes.
i.e sprintf and whatever else needs to be linked in to get it to work, takes just under 19kb.
However as the device has a lot more room than the smaller AVR's I don't think its too much of an issue.

I'll investigate adding Serial.printf to the core. (i.e using sprintf)




Title: Serial.printf :-(
Post by: rogerClark on Nov 01, 2014, 07:36 am
I've taken a look at implementing the full printf for Serial and it appears to be possible.

However I don't know how to write the stream class that would be required.

i.e

I added a printf function to the Print class that is used for Serial.print

Code: [Select]
#include <stdio.h>
#include <stdarg.h>
// To Do. Implement the stream class to make this possible
int Print::printf (__const char *__restrict __format, ...)
 {
FILE *__restrict __stream;
     int ret_status = 0;


     va_list args;
     va_start(args,__format);
     ret_status = vfprintf(__stream, __format, args);
     va_end(args);
     return ret_status;
 }


However there would need to be a FILE "stream" class implemented, which wrote the characters to the serial port in question.

And personally I'm not entirely sure how to implement a stream like this.



However, I'm beginning to wonder if the overhead of this is really necessary, when its possible to setup a buffer, then user sprintf followed by Serial.print

Adding fprintf makes makes the code 3k bigger than using sprintf, and thats without the implementation of the serial stream, which is probably going to be 10k, unless it can be cut down because fprintf is not using all the functions


Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 01, 2014, 08:13 am
Roger, I didnt realise you (and Bob) had done so much to show horn this into the IDE

So, to recap is it just a case of grabbing the repo (https://github.com/rogerclarkmelbourne/Arduino_STM32) and copying the contents into the Arduino/hardware folder, run IDE and select device as normal ?

So will this work on the non-official maple boards, like the one I bought at the beginning of this topic ?
http://www.ebay.co.uk/itm/ARM-Cortex-M3-Leaflabs-Leaf-Maple-Mini-Module-STM32-for-Arduino-/111450858151?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item19f2fd22a7 (http://www.ebay.co.uk/itm/ARM-Cortex-M3-Leaflabs-Leaf-Maple-Mini-Module-STM32-for-Arduino-/111450858151?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item19f2fd22a7)

Cheers
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 01, 2014, 10:10 am
@john1993
Do you mean add printf to Serial ?

I just tried using sprintf and it doesn't seem to be part of the Maple core.
However it is part of Arduino SAM (Due), so it should be possible to bring it across fairly easily as it doesn't do anything that's hardware specific.

Anyway, let me know if this is what you mean.
what i was trying to say is there are some basic functions needed for somebody who is just starting out with these new boards and odd bootloaders are not it. it seems since these devices already have a 100 percent tested and functional bootloader built-in at the factory little more is needed in that direction atm. almost everybody else in the world has an ftdi type serial/usb adapter. it would be great to play with one of these cheap arm boards using the manufacturers program utility instead of struggling with python scripts and other extraneous issues. sort of like using usbasp for arduino instead of all those 3rd party bootloader software and hardware issues. specially considering the built-in usb hardware dont work on some.

it looks to me like a few essentials for example being able to print out a serial port and talk to spi and i2c devices and simple tutorial would get a lot of people hooked on this. i just ordered one of these new arm boards and it would be great if there was some way to make it work when it arrives without jumping through hoops.

reading through this thread again its not clear what the state of the project is in this respect. if we download from github and try the led blink program will it work? what about a nrf24l01, sd card, or lcd demo? with basic spi/i2c (bit bang vs mcu hardware dont matter) these should just go. right?

i though about learning arm with arduino due but they are not available for $4 from china. is there some way to marry atmel sam routines with whats available from maple and make serial/spi/i2c work with either of the ide? i wish i knew more about this new architecture or i would jump in myself.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 10:13 am
@mcnobby

Yes. copy my repo into My Documents/Arduino/Hardware and select the Maple mini

(Bobs original repo works fine for that board, as it is a maple mini clone)

My repo adds support for generic STM32 boards without bootloader, which can be uploaded via an external USB to serial converter.

I have also added Wire (I2C) which is not in bobc's original version
I've also fixed the issue of memcpy etc being missing etc etc

Anyway, download either and give them a try

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 12:06 pm
@john1993

Quote
if we download from github and try the led blink program will it work
The Maple mini and generic STM32 boards are not for beginnners, but if you have used an Arduino pro mini or any of the other boards e.g. a Arduino Micro (with USB), you would feel at home.


However, the normal Blink program won't run because neither the Maple mini or the generic STM32 have the LED on the same pin (13) as the Uno (goodness knows why Maple chose to put their LED on a "pin" that was not enumed to be pin 13

#define BOARD_LED_PIN             33

Actually the larger Maple board (I don't know if anyone has one of these) has the LED pin as 13 but none of the boards that seem to be available e.g. via eBay have it on pin 13.


The Blink example from the maple ide looks like this

Code: [Select]
void setup() {
    // Set up the built-in LED pin as an output:
    pinMode(BOARD_LED_PIN, OUTPUT);
}

void loop()
{
    toggleLED();          // Turn the LED from off to on, or on to off
    delay(100);          // Wait for 1 second (1000 milliseconds)
}



The generic STM32 board I have is slightly different again. Its led is on pin PC13 but the code to blink is the same on the generic STM32 as on the maple mini.


But. Actually getting to the point where you can upload to the Maple mini, is somewhat problematic, because of driver signing issues in Windows 7 or newer.

The Maple usb driver is not signed, so you have to reboot windows and press F8 and boot with driver signing disabled (or use another similar work arouind) every time you want to upload to the Maple mini.

Plus there is another setup procedure you have to run once, to get the Maple in DFU mode where it enumerates on USB as a programmable device.

I've not got a Maple mini, but @mrarduino has done this and it works OK.


I've got an unbranded generic STM32 board which doesn't have the extra hardware that the Maple mini board has, to force the PC to re-enumerate the USB bus and load the DFU drivers.
So I can't upload to the onboard USB.


But I you can upload to the STM32 board (and the Maple Mini - AKIF), using a USB to Serial adaptor.

So basically, using the Generic STM32 board is like using an Arduino Pro mini board, that doesn't have a reset line attached to the USB to serial


To Upload, I have to press reset before I start the compile / upload problem, but there are no timing issues, the STM32F103 stays in a mode to accept serial data for ages.

So I press reset then press upload on the Arduino IDE and all is fine.


What else works.. Its hard to say, mainly because no one has tested it.

I know that  Wire (I2C) now appears to work (in my repo, but not bobc's), because I've spent several hours getting it to work.
However libraries like I2CDev that use the normal Arduino implementation of I2C don't currently compile
(actually I now have a version that compiles, but doesn't work yet, so I've not put it in my repo)


I've added SPI, to my repo, but I doubt currently even compiles - the changes needed to get it to compile would be trivial, they are just include paths, but I've not had time to look at or test this as my focus has been I2C



Quote
nrf24l01, sd card, or lcd demo?
Currently untested on all fronts.

I suspect once SPI is working, I can't see why the NRF24L01 would not work except if the SPI implementation was serious odd.

Same for SD card (as thats SPI)

Not sure about lcd (depends on which display you mean)



Overall, there is a lot of Maple based code, kicking around in various places on the web, most of which appears to work, e.g. for CAN bus, EEPROM and loads of other things

But the Maple core code was written to the Arduino 0022 spec, and some API changes were made to go to .ino files at Arduino 1.0

e.g. I had to modify the original Wire library that Maple wrote, because of changes to the function names

And currently the I2CScanner from the playground doens't work because it looks like the return value from Wire.endtransmission, has changed .



Personally, I think this is a wonderful little board. Its cheap and fast and has more program space, more ram, better peripherals than the corresponding Arduino board.

It will just take a bit of time and effort to update all the old Maple code so that it works with Arduino 1.5.x
And also to bug fix


The issue of the bootloader and drivers however is a more thorny issue.

I think the general consensus is that Maple made a mistake not using an FTDI chip for USB to serial

Personally, I agree, but think that using a 32U4 or something similar instead is probably the best option if anyone wanted to build a cheap Arduino compatible board, as we could use the Uno drivers ;-)


Anyway.  I doubt that this has even scratched the surface of your questions, but I hope it helps


BTW.

Quote
i just ordered one of these new arm boards
Can you link to the boards you have ordered ?

I currently just have an unbranded generic mini STM32 board, I have a larger STM32 (Uno size) in the post (on the slow boat from china), and also 2 x Maple mini clones (also on a slow boat from china)

So it will be interesting when they all finally arrive





 
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 01, 2014, 02:18 pm
thanks for the summary. it clears up some confusion over current status.

its worth mentioning that im an electrical engineer and many years experience with avr, arduino, and other mcus. arm not so much. being involved academically too there is great motivation for me to seek out most trouble free tutorials and easiest path to help those just starting out.

However, the normal Blink program won't run because neither the Maple mini or the generic STM32 have the LED on the same pin
this is quite trivial. anyone who doesnt know how to hook an led up to another pin is in the wrong hobby. like with many 2nd generation arduino boards it does look like maple pin numbering involved some number of monkeys typing randomly on keyboards. personally i would have selected so the demos work with as little modification as possible. too late to change now i guess.

Can you link to the boards you have ordered ?
got a couple of these on the way:

http://www.ebay.com/itm/221557255044?_trksid=p2055119.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT

considered cheaper ones from alibaba but i dont really trust those guys as much.

it would be nice to initially avoid getting involved with that built-in usb baloney. specially after issues mentioned above.  afaik better to stick with generic usb/serial adapters which have few problems under windows regardless of version. also would be nice to integrate the manufacturers programming utility into the ide like arduino did with usbasp. path of least resistance is my motto.

i understand this is a work in progress and appreciate the effort you and others are putting into this. hopefully by the time my board arrives at least led blink will be warm and fuzzy and maybe isp/i2c soon too. then tapping off the arduino base should allow thousands of useful apps to become available w/o much trouble.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 01, 2014, 02:55 pm
@mcnobby - Yes. copy my repo into My Documents/Arduino/Hardware and select the Maple mini
Brilliant - I cant wait to give this a try !!!
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 01, 2014, 03:40 pm
oohh.... That's handy... So I can run a Maple Mini from the Arduino IDE! Well done chaps, I have 1 to test now...(And a few to sell on eBay)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 08:20 pm
@john

I have already integrated uploading via external USB to serial into the IDE using a utility exe called stm32flash

The only caveat is that you need to put the chip into serial upload mode before starting to compile.

I think on the Maple mini, you do this by holding down a button, while pressing and releasing the reset button. Note. AFIK the maple mini has 2 push buttons, one of which is reset and the other is connected to boot0 on the stm32, but if I get chance I will check the schematic.

On my generic board, there is a jump link on boot0, which I generally leave set ON all the time while developing, so I only need to press reset.

After that the process is the same as a UNO etc. ie you only need to press upload in the IDE and wait for it to compile and upload.

I will try to put a tutorial on my blog today.




Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 01, 2014, 10:23 pm
im sure your description of the boot process is correct as it matched what i find on several websites. two switches on the maple board make it easy. integrating into the ide is a big advantage so thanks for that. my boards are a couple weeks out so this project will probably be much further along by then. i cant wait.

im tickled pink to see serial is up and running. that is probably the single most important function after blink because of debug potential.

incidently the blink you posted is for 100ms. is it really intended to blink that fast or is that a typo or is there some kind of clock compensation going on? did you try it yourself? i know there is an enormous difference between avr and arm timers so that seems to be the big deal getting it to work. not so much the bit wiggle part.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 10:47 pm
@john1993

I've posted a tutorial on my blog, which I hope covers the basics

http://www.rogerclark.net/?p=805 (http://www.rogerclark.net/?p=805)

Re: Blink rate

I posted that in a hurry. I was initially using the blink speed as an indication of whether I'd managed to actually upload a new version of blink to the flash memory, or whether it was still running the previous one.
i.e I kept changing the delay values

The sketch in my blog corrects this

Re: Serial it works fine to USB

I've just made a change to my code, so that for serial USB users, the Serial mapping is the same as the Mega. But I was messing around with adding Serial.printf  - however its going to take too long to implement, so I need to comment out the code I did, so far, to support Serial.printf until I can work out how to implement a FILE stream  e.g. like STDIO

However I'll try to upload the new / improved version in about an hour after I've had some breakfast ;0)

Edit.

BTW. Serial.print and Serial.println already work fine, I was just experimenting with adding Serial.printf

e.g

Serial.printf("The temperature is %g",tempVal);
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 01, 2014, 11:57 pm
Guys,

I've updated my repo on Github to add support for sprintf (which was not working due to a missing include) and also for the generic STM32 i.e USB to Serial connected boards - I've changed the definitions of Serial, so that there is a Serial for the non-bootloader version, hence

Serial maps to UART1 (should be connected to USB to serial for uploading)
Serial1 maps to UART2
Serial2 maps to UART3 etc


I also investigated adding printf, but have #ifdef'ed out my code as I've not finished it.

If anyone wants to test sprintf with Serial.print

try this variation of Blink.



Code: [Select]

char strBuf[64];


void setup() {
    // Set up the built-in LED pin as an output:
    pinMode(BOARD_LED_PIN, OUTPUT);
    pinMode(PC13, OUTPUT);
    Serial.begin(115200);
    Serial.println("Hello world");
}

void loop()
{
    toggleLED();          // Turn the LED from off to on, or on to off
    togglePin(PC13);

    sprintf(strBuf,"Mills in seconds is  %g\n",millis() / 1000.0);
    Serial.print(strBuf);
    delay(500);       
}



Note. I think on the Maple that the Serial is called SerialUSB  perhaps someone with a Maple board can confirm this.
e.g. It appears to be so from this page on leaflabs site
http://leaflabs.com/docs/ide.html (http://leaflabs.com/docs/ide.html)

I'm not sure if this is the case, why Maple decided to have a completely separate function / object for this.  Albeit, it looks like there could be errors if the USB is not connected, but it should be possible to handle SerialUSB.isConnected() in Serial.begin

I know in this case Serial.begin would have no purpose, as its controlled by the driver not by the board, but I'm also sure that a dummy function could be added for Serial.begin


Title: Re: What's this I found on eBay?
Post by: westfw on Nov 02, 2014, 12:32 am
Quote
I wonder if it would be practical to build all the core files into a lib rather than having to link all the .o files each time there is a build.
Probably.  IIRC, the current AVR code no longer recompiles all the library/core files for every build, and the main reason it didn't initially is that it was using the same core source code for chips with relatively significant differences (atmega8 vs atmega168, for example.)  (and the cores for AVR were pretty small.)  For the STM32f chips, the peripherals and other details are all pretty much in the same place from chip to chip...
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 02, 2014, 12:49 am
@westfm

Thanks.

Looks like something to put on the ToDo list (near the bottom of the list)

I took a quick look at the verbose output from a compile and the IDE seems to compile all the core files just after it compiles the "sketch" and stores them in the temp dir for the build.

e.g.

-o C:\Users\myuser\AppData\Local\Temp\build2387694249689173463.tmp\adc.c.o

Like you say, the reason for this is probably because switching boards can change the defines in the boards.txt that are used.

However a better way to do this would be for the IDE to have some sort of flag to indicate if the default board had been changed and if so do some sort of Make_All rather than Make

Actually, its not even doing a make really, as if it did, the .o files for the core stuff would only get recompiled the first time you opened the sketch and compiled it (albeit if you closed the IDE and opened again and then compiled, it would need to recompile the whole lot, but thats not what would be happening most of the time)

Its strange that the Arduino team didn't employ any form of Make based build

Title: Re: What's this I found on eBay?
Post by: westfw on Nov 02, 2014, 08:36 am
Quote
Its strange that the Arduino team didn't employ any form of Make based build
Standard "it seemed simpler at the time, to not use Make, and the amount of code built was small anyway."  Followed by years of feature creep and "but we don't use make."

Perhaps libraries and cores offer an opportunity for a transition, by using Make if a Makefile is present in the directory: https://github.com/arduino/Arduino/issues/2400
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 02, 2014, 09:32 am
Good work Roger, your BLOG makes very good reading, its nice when all the information is in one place like that, if someone had to try and find the right part of this 12 page topic they would probably need to read everything... So its MUCH appreciated !!!
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 02, 2014, 09:56 am
for those who may be interested in incorporating the stm32f103c8t6 into their own projects, I have found these

http://www.ebay.co.uk/itm/5PC-x-New-STM32F103C8T6-LQFP-48-STM32F103-ST-A108-AR1-/171339286824?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item27e49e0928 (http://www.ebay.co.uk/itm/5PC-x-New-STM32F103C8T6-LQFP-48-STM32F103-ST-A108-AR1-/171339286824?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item27e49e0928)

which works out to be £1.66 each delivered !

thats only a bit more than buying Atmega328's in the same quantity for considerably MORE firepower
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 02, 2014, 10:45 am
Good work Roger, your BLOG makes very good reading, its nice when all the information is in one place like that, if someone had to try and find the right part of this 12 page topic they would probably need to read everything... So its MUCH appreciated !!!
No worries.

I should do that with some of my other projects, but its quicker to post to the Arduino forum sometimes (writing to the blog takes ages ;-0)



Anyway.

I've looked at SPI support and currently although SPI is supported the Maple API is completely different from the Arduino SPI, in that there is no SPI.h in fact no SPI folder at all in the libraries.

Maple has its own special SPI class  HardwareSPI, and there are examples of how to use it in the Maple wiki.


So what needs to be done is to copy either the AVR or SAM SPI files, into the maple libraries folder, then look at what methods need to be supported , then port the AVR or SAM code and replace it with code that calls the maple HardwareSPI class



I did start to look at this today, but just trying the basic "SPI Barometer" example sketch that comes with the Arduino IDE (It only appears if you select an Arduino board not the Maple boards), failed before it even looked for the SPI class.
This was because there was no String class in the Maple core code.

So I've copied the WString stuff from Arduino SAM implementation, into the Maple code and updated the Print class to support Serial.print(const String) and also println(...  etc


Which has taken all the time I have for today, so I'll need to look at SPI another day (i.e as its 8:30pm here)


I've pushed an update to my GitHub repo that has this in it.

I've also taken the examples that are only in the Maple IDE package (the whole IDE can be downloaded from here, http://static.leaflabs.com/pub/leaflabs/maple-ide/maple-ide-0.0.12-windowsxp32.zip  if anyone really wants the whole IDE) and copied them into my repository, after first renaming all the files from .pde to .ino

Note. I have not tested any of the examples, it seemed a good idea to move them into a location where people could easily access them, and the readme.txt in the IDE zip package states the whole thing is open source, and doesn't seem to state any restrictions, so I can't see a license problem with doing this.

I suspect a lot of the examples may not compile, as they would have been written to be compatible with the Maple IDE which is pre- Arduino 1.0 (i.e its the Arduino 0022 API).
Nevertheless they may be of some benefit.

Cheers

Roger

Edit. I forgot to mention. I noticed that the return types on the print methods is now size_t but is void in the Maple print files.
So, thinking about it, I will probably port the SAM print.cpp and print.h to Maple, as I think there is very little to port, because I think there are only 2 platform specific internal methods, I.e the ones that write the chars to the hardware.

The SAM port seems to have additional code for serial callbacks, but that will take more time to port, so I think initially I will just make sure everything returns size_t to correspond with what the avr version does.


Actually the lack of a real serial interrupt on the avr is a bugbear of mine, but that's a different story ;-)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 02, 2014, 12:11 pm
@westfw

Apologies for calling you westfm for ages.. I blame auto correct ;-)

Also. I just tied to comment on your github issue, but failed on the ipad.

I was going to suggest that the make file name could be specified in the boards.txt,
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 02, 2014, 02:37 pm
Just a quick question Roger...

My STM32 board has a USB socket on it, your blog talks about using a USB>serial rather than using the local USB socket, is that correct ? I had a quick read of Mr Burnettes stuff but couldnt find any reference to the USB programming side of the STM32

PS, downloaded the (new) IDE and added the files from your repo, so far all works fine.. its just the connection to the device now....

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 02, 2014, 04:29 pm
I was just looking a little further into available 'blank' micros for 32bit projects, and wanted to see what the comparison was between the STM32F103C8T6 and the Due microprocessor (AT91SAM3X8E)

After all, if you are going to start developing on a particular platform, you might be thinking 'how would I actually make several of these without having to use the devkits ??'

The obvious big difference between the two is the rom/ram/IO..

SAM3X : I kind of start to think do I need 512k of flash and 96k of ram and all that IO ?? and also do I really want to be soldering a shed load of pins ?

STM32 : But then I start to wonder if 64k of flash is enough even though the huge 20k ram surely IS ? the device is a lovely LQFP48 which is a doddle to solder
 
its rather an odd comparison I am making here, but I am doing it as part of a cost-vs-power exercise I am doing for a few future projects, the STM32 is VERY cheap in low quantity but I couldnt find a good price for the SAM3X so it is difficult to make a true comparison...

I also started looking at the Teensy3.1, it has 256k rom and 64k ram @ 72mhz, kind of half way between the STM32 and the SAM3x

By making the STM32 a pseudo-Arduino platform this has opened up a new (very cost effective) gateway between MEGA and DUE (which I like very much)

I can imagine many many users have upgraded to the 644/1284/2560 still only to find they require more speed rather than ram/rom, I know I have, and sometimes its not always code efficiency that is to blame (although unless you write solely in assembler you might never know)

I might get shot down in flames for my novice-opinions, but its really just a few things I am throwing into the pot here just in case there are users out there (like me) that like to think of a potential future for their projects other than sat on dev boards

:)
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 02, 2014, 04:43 pm
Well, we will be stocking the Maple Mini clones when we have tested them... so hopefully there is a UK market. The ones we have are a reliable make as well. (We sell their Pro Minis and CH340 USB to serial converters and have had no complaints about them)
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 02, 2014, 06:06 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
By mhaking the STM32 a pseudo-Arduino platform this has opened up a new (very cost effective) gateway between MEGA and DUE (which I like very much)
<....>
I might get shot down in flames for my novice-opinions, but its really just a few things I am throwing into the pot here just in case there are users out there (like me) that like to think of a potential future for their projects other than sat on dev boards
The huge interest in the Pro Mini from Sparkfun under $10 or the Chinese clones of Pro Mini at under $3 indicate to me that many Arduino users want a cost-effective & compatible solution for the more-than-one scenario.  Also, lately I have fielded more dialog with bare-bones builders than ever before in the forum.

I am a big proponent for moving Arduino into multiple uC architectures.  We are fortunate in the forum to have members with the ability to port/migrate libraries and core-code to support non-Atmel uC and also the desire to experiment and provide testing. 

I personally went to 1284 for headroom, but 16MHz (20+ over clocked) base clock is often the real issue.  A clock-cycle or two may be gained by eliminating PROGMEM as more static structures are moved to SRAM, but there is still overhead at 8-bit in manipulating 16-bit default Int values.  Even using fast pin I/O still is a bandaid approach.  The jump to 32-bit with 20K+ of SRAM and clocks of 48MHz, 72MHz, and higher is a huge game changer, IMO, since the performance is not a few percentage points BUT 100% - 300% or more and at no greater outay in hardware (chip) co$t.  What is not to like??


Ray
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 02, 2014, 06:26 pm
I think it is brilliant.  Not only have non standard (in terms of the  Arduino world) uCs been brought into the fold, now bringing in other manufacturers boards can only help makers.

It would be good to get this support built into the mainstream IDE though.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 02, 2014, 08:41 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
It would be good to get this support built into the mainstream IDE though
From my understanding, the shift from GUI 1.0.x to 1.5.x is the best a 3rd party can do: that is, the support structure is in the GUI for implementation.  From an out-of-the-box support however, that will only be provided for genuine Arduino and 2nd party official partners: Sparkfub, Adafruit, etc.

The partners provide a revenue stream back to Arduino to support integration efforts for the official products and for costs of website store and forums.  This scenario allow use of Arduino and logo and maybe sdome additional benefits.

3rd party efforts bring nothing in the way of revenue, rather they are a negative cash operation (if for no reason than forum "noise").  So, there is simply no incentative for Arduino to support these products.  The facts are that hooks have been graciously provided is Arduino's open support for choice and the maker movement in general.

Leaflabs may have been able to operate within Arduino 2nd tier, but chose to hack the GUI and go it alone.  This is the same for Paul and the Teensie.  I am sure the decision by each was complex; however, Arduino is a moving and evolving platform and Leaflabs made it clear on their website that they use the Maple products internally for consulting work - thus, I can understand that they want to maintain full-control.  Why Paul at Teensy elected an Arduino "overlay" rather than 2-tier support as did Sparkfun is unknown but his approach has not seemed to have hindered his sales or creativity.

Point is, I do not think that out of the box support for STM32 is a big deal IF the user community can reach critical mass and maintain the core files.  This just happened this year with the Atmega1284P group who published a revised/refreshed core on Github for Arduino 1.0.5.


Ray
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 02, 2014, 09:56 pm
3rd party efforts bring nothing in the way of revenue, rather they are a negative cash operation
Surely that is open source for you...

Quote
We are fortunate in the forum to have members with the ability to port/migrate libraries and core-code to support non-Atmel uC and also the desire to experiment and provide testing. 
And I totally agree with you about that, I personally feel quite blessed to be in the midst of some pretty clever chaps, and such an awesome forum too !!
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 02, 2014, 10:09 pm
for those who may be interested in incorporating the stm32f103c8t6 into their own projects, I have found these

http://www.ebay.co.uk/itm/5PC-x-New-STM32F103C8T6-LQFP-48-STM32F103-ST-A108-AR1-/171339286824?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item27e49e0928 (http://www.ebay.co.uk/itm/5PC-x-New-STM32F103C8T6-LQFP-48-STM32F103-ST-A108-AR1-/171339286824?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item27e49e0928)
those (c8t6) are not the same as used for maple (cbt6). afaik the only difference is 128k vs 64k flash. does your project support both? i hope so because they are a lot cheaper and few programs need the extra.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 02, 2014, 10:15 pm
ok, I see... very confusing to have C8T6 and CBT6, personally if I was coding part numbers I would make them a little less ambiguous ;)
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 02, 2014, 10:34 pm
i agree. however it would be nice if roger supported both. according to stmicro they are virtually identical except for flash size. it would be super easy to build on one of those cheap smd adapters and would cost half as much as a maple.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 02, 2014, 10:46 pm
I'm with you on that one John ! :)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 02, 2014, 11:00 pm
Hi Guys,

I seem to be having issues posting this morning

@mcnobby

I tried to see if I could use a regular arduino as a serial bridge to the STM32 board, but could not get it to work.
I think the issue is that the Arduino probably reboots when stm32flash opens the comm port, so I'd need to recompile stm32flash (which I"m having difficulties doing with Code::Blocks due to missing headers and possibly missing libs)

Re: Supporting different STM32 variants

I don't think it would be too hard to do this

Currently in the boards file there is a define for the CPU type e.g.

maple_STM32.build.extra_flags=-DMCU_STM32F103CB -mthumb -MD -DSTM32_MEDIUM_DENSITY  -march=armv7-m

MCU_STM32F103CB

This is the one I'm using as its the one Maple used for the mini.
My board actually contains a STM32F103C6T not a 103CB

I will investigate the differences

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 02, 2014, 11:48 pm
STM32F103C6T does not appear to be an stmicro part. maybe a chinese clone. i wonder what will be on the ones i ordered. could you post a link or photo of your board?
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 02, 2014, 11:59 pm
The boards I have contain 1 chipped marked as follows:

STM32
F103CBT6
GH223 9U
CHN302

I will try them on the Maple IDE when I am next on a Windows machine.

ST Micro have this about the chip on their website (http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1031/LN1565/PF189782?sc=internet/mcu/product/189782.jsp).
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 03, 2014, 12:09 am
I just double checked the markings on my chip and its an

STM32F103C8T6

I found this (see image from pdf)

STM32F103C8xx = 64k flash
STM32F103CBxx = 128k flash

so my board is 64k flash

But all STM32F103 "medium density" devices appear to be 20k ram

I'll modify my boards file to cater for both C8 and CB types (shame they chose 2 letters / numbers which look virtually the same)




Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 03, 2014, 12:10 am
Found this file which makes use of the defines

Code: [Select]
/******************************************************************************
 * The MIT License
 *
 * Copyright (c) 2010, 2011 LeafLabs, LLC.
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy,
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *****************************************************************************/

/**
 * @file libmaple/stm32f1/include/series/stm32.h
 * @brief STM32F1 chip- and series-specific definitions.
 */

#ifndef _LIBMAPLE_STM32F1_H_
#define _LIBMAPLE_STM32F1_H_

#ifdef __cplusplus
extern "C" {
#endif

#define STM32_MCU_SERIES                STM32_SERIES_F1

/* The STM32F1 series is subdivided into "lines". libmaple currently
 * officially supports STM32F103 performance line MCUs (see the
 * MCU-specific value section below).
 *
 * You can use these F1 line defines if porting libmaple to support
 * MCUs on other lines. */
/** STM32F1 value line (STM32F100 MCUs). */
#define STM32_F1_LINE_VALUE             0
/** STM32F1 access line (STM32F101 MCUs). */
#define STM32_F1_LINE_ACCESS            1
/** STM32F1 USB access line (STM32F102 MCUs). */
#define STM32_F1_LINE_USB_ACCESS        2
/** STM32F1 performance line (STM32F103 MCUs). */
#define STM32_F1_LINE_PERFORMANCE       3
/** STM32F1 connectivity line (STM32F105/F107 MCUs). */
#define STM32_F1_LINE_CONNECTIVITY      5

/*
 * MCU-specific values.
 *
 * You can use this section to override any of the below settings on a
 * per-MCU basis. For example, if your MCU has different STM32_PCLK1
 * or STM32_PCLK2 values, you can set them here and the values for
 * STM32F103 microcontrollers set below won't take effect.
 */

#if defined(MCU_STM32F103RB)
#   define STM32_F1_LINE                STM32_F1_LINE_PERFORMANCE
#   define STM32_NR_GPIO_PORTS          4
#   define STM32_SRAM_END               ((void*)0x20005000)
#   define STM32_MEDIUM_DENSITY

#elif defined(MCU_STM32F103ZE)
#   define STM32_F1_LINE                STM32_F1_LINE_PERFORMANCE
#   define STM32_NR_GPIO_PORTS          7
#   define STM32_SRAM_END               ((void*)0x20010000)
#   define STM32_HIGH_DENSITY

#elif defined(MCU_STM32F103CB)
#   define STM32_F1_LINE                STM32_F1_LINE_PERFORMANCE
    /* This STM32_NR_GPIO_PORTS is not true, but only pins 0 and
     * exist, and they're used for OSC (e.g. on LeafLabs' Maple Mini),
     * so we'll live with this for now. */
#   define STM32_NR_GPIO_PORTS          3
#   define STM32_SRAM_END               ((void*)0x20005000)
#   define STM32_MEDIUM_DENSITY

#elif defined(MCU_STM32F103RE)
#   define STM32_F1_LINE                STM32_F1_LINE_PERFORMANCE
#   define STM32_NR_GPIO_PORTS          4
#   define STM32_SRAM_END               ((void*)0x20010000)
#   define STM32_HIGH_DENSITY

#elif defined(MCU_STM32F100RB)
#   define STM32_F1_LINE                STM32_F1_LINE_VALUE
#   define STM32_NR_GPIO_PORTS          4
#   define STM32_TIMER_MASK             0x380DE /* Timers: 1-4, 6, 7, 15-17. */
#   define STM32_SRAM_END               ((void*)0x20002000)
#   define STM32_MEDIUM_DENSITY

#elif defined(MCU_STM32F103C8)
#   define STM32_NR_GPIO_PORTS          4
#   define STM32_SRAM_END               ((void*)0x20005000)
#   define NR_GPIO_PORTS                STM32_NR_GPIO_PORTS
#   define STM32_F1_LINE                STM32_F1_LINE_PERFORMANCE
#   define STM32_MEDIUM_DENSITY

#else
#warning "Unsupported or unspecified STM32F1 MCU."
#endif

/*
 * Derived values.
 */

#if STM32_F1_LINE == STM32_F1_LINE_PERFORMANCE
     /* All supported performance line MCUs have a USB peripheral */
#    define STM32_HAVE_USB              1

#    ifdef STM32_MEDIUM_DENSITY
#       define STM32_NR_INTERRUPTS      43
#       define STM32_TIMER_MASK         0x1E /* TIMER1--TIMER4 */
#       define STM32_HAVE_FSMC          0
#       define STM32_HAVE_DAC           0
#    elif defined(STM32_HIGH_DENSITY)
#       define STM32_NR_INTERRUPTS      60
#       define STM32_TIMER_MASK         0x1FE /* TIMER1--TIMER8 */
#       define STM32_HAVE_FSMC          1
#       define STM32_HAVE_DAC           1
#    elif defined(STM32_XL_DENSITY)
#       define STM32_NR_INTERRUPTS      60
#       define STM32_TIMER_MASK         0x7FFE /* TIMER1--TIMER14 */
#       define STM32_HAVE_FSMC          1
#       define STM32_HAVE_DAC           1
#    endif

#elif STM32_F1_LINE == STM32_F1_LINE_VALUE
     /* Value line MCUs don't have USB peripherals. */
#    define STM32_HAVE_USB              0

#    ifdef STM32_MEDIUM_DENSITY
#        define STM32_NR_INTERRUPTS     56
#        define STM32_HAVE_FSMC         0
#        define STM32_HAVE_DAC          1
#    elif defined(STM32_HIGH_DENSITY)
         /* 61 interrupts here counts the possibility for a remapped
          * DMA2 channel 5 IRQ occurring at NVIC index 60.  */
#        define STM32_NR_INTERRUPTS     61
#        define STM32_HAVE_FSMC         1
#        define STM32_HAVE_DAC          1
#    endif

#endif

/*
 * Clock configuration.
 *
 * You can patch these for your line, MCU, clock configuration,
 * etc. here or by setting cflags when compiling libmaple.
 */

#if STM32_F1_LINE == STM32_F1_LINE_PERFORMANCE
#    ifndef STM32_PCLK1
#    define STM32_PCLK1                     36000000U
#    endif
#    ifndef STM32_PCLK2
#    define STM32_PCLK2                     72000000U
#    endif
#    ifndef STM32_DELAY_US_MULT
#    define STM32_DELAY_US_MULT             12 /* FIXME: value is incorrect. */
#    endif
#elif STM32_F1_LINE == STM32_F1_LINE_VALUE        /* TODO */
#    ifndef STM32_PCLK1
#    define STM32_PCLK1                     12000000U
#    endif
#    ifndef STM32_PCLK2
#    define STM32_PCLK2                     24000000U
#    endif
#    ifndef STM32_DELAY_US_MULT
#    define STM32_DELAY_US_MULT             8 /* FIXME: value is incorrect. */
#    endif
#elif STM32_F1_LINE == STM32_F1_LINE_ACCESS       /* TODO */
#elif STM32_F1_LINE == STM32_F1_LINE_USB_ACCESS   /* TODO */
#elif STM32_F1_LINE == STM32_F1_LINE_CONNECTIVITY /* TODO */
#endif

/*
 * Sanity checks.
 *
 * Make sure we have the F1-specific defines we need.
 * <libmaple/stm32.h> will check that we've defined everything it needs.
 */

#if !defined(STM32_F1_LINE)
#error "Bad STM32F1 configuration. Check STM32F1 <series/stm32.h> header."
#endif

/*
 * Doxygen
 */

#ifdef __DOXYGEN__

/**
 * @brief STM32 line value for the STM32F1 MCU being targeted.
 *
 * At time of writing, allowed values are: STM32_F1_LINE_PERFORMANCE,
 * STM32_F1_LINE_VALUE. This set of values may expand as libmaple adds
 * support for more STM32F1 lines.
 */
#define STM32_F1_LINE

#endif /* __DOXYGEN__ */

#ifdef __cplusplus
}
#endif

#endif
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 03, 2014, 12:18 am
They are very capable chips.... Can do 2 UART, USB, CAN bus... 12 bit ACD.... the list goes on.

Title: Re: What's this I found on eBay?
Post by: westfw on Nov 03, 2014, 12:21 am
Quote
Apologies for calling you westfm for ages.
I was wondering about that, but it didn't seem worth correcting.  Thanks for noticing.

Quote
then I start to wonder if 64k of flash is enough
"Upgrading" from AVR to ARM with similar amounts of memory is a bit ambiguous there, especially since ARM tends to have more overhead (Blink on Maple is 10k!)  OTOH, you gain a lot of speed, especially if you're doing 32bit math (~16x faster?)  And there IS a pin-compatible 32f103cbt6 chip that has 128k.  (some mini clones may have this larger chip.)  (and ST has "similar" chips with up to 2M of flash.)  Working with packaged libraries for ARM can be frustrating, because the authors usually think along the lines of "I have lots of memory", and when you go to put their code in one of the really cheap 8-bit-replacement CM0 chips that only has 32k (or less!), you run into problems.

I just ordered some of these: http://www.aliexpress.com/store/product/leaflabs-Leaf-maple-mini-ARM-STM32-compatibility/213957_1400667476.html
$5!  "Baite" has been recommended as a reputable dealer; some of the cheap boards I've ordered from elsewhere have had "Baite" silkscreen markings...   Sheesh.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 03, 2014, 12:23 am
Is this the part number on one IC

Quote
STM32
F103CBT6
GH223 9U
CHN302
its only th3 F103CB thats the important bit

the rest is just the package etc

ie its a C series 128k flash
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 03, 2014, 12:28 am
I'm going to change my boards.txt for the generic STM32 and put in for both C8T and CBT

It looks like the Maple file already handles this. However I'm pretty sure EEPROM doesnt handle C8T (though I"ll double check)
However the change to EEPROM.h should be simple.

Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 03, 2014, 12:30 am
.
Is this the part number on one IC

its only th3 F103CB thats the important bit

the rest is just the package etc

ie its a C series 128k flash
Yes it is. Read directly from the Chip.
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 03, 2014, 12:42 am
I've just been skimming some more... 16 interrupt vectors and an onboard RTC with a temperature sensor? Does it make the tea as well?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 03, 2014, 01:15 am
Its determinately quite a powerful device.  Not as good as the Core M4 in the Teensy, but value for money is good.


I don't know if LeafLabs did anything with the RTC functionality, I took a quick look to see what millis() does, but it wasnt obvious, but didnt look on the face of it, to be using the RTC (possibly the RTC only has 1 second resolution)

It looks like someone already wrote an RTC library

https://github.com/bubulindo/MapleRTC

It should be pretty easy to put in the libraries folder

Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 03, 2014, 01:20 am
Frankly it rocks... also there is the question of what can be done with the onboard temperature sensor.

It does seem from the docs that the RTC may need calibration and the board I have doesn't look like it has a crystal, though it does have a black device marked:

8.000
103

(And some symbol to the right of the 103 that looks like a sawtooth)
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 03, 2014, 01:40 am
So ...
I'll be at this seminar next week: STM32L0 Ultra-Low-Power MCU Seminar (http://www.st.com/web/en/seminar/stm32l0)
I find these things relative useful in a professional context; though I'm not quite sure that they're worth an entire day.  Even when the content is relatively non-technical, I find it useful to get a more-detailed view of a company's technical strategy toward a product line.  In this case, I'm particularly curious about the whole "STM32Cube vs 'other'" development methodologies.
And hey!  Free toys!
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 03, 2014, 09:51 am
I had a look at Leaf labs website and it appears they are discontinuing the boards. I wonder if someone could persuade ST to look at funding getting the chip embedded into the Arduino platform...
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 03, 2014, 10:55 am
I had a look at Leaf labs website and it appears they are discontinuing the boards.
I don't see why this is an issue.

The chinese manufacturers seem to have started to make Maple Mini clones (i.e that's what most people in this thread seem to be using). (Mine still have not turned up yet :-(

Title: RealTime Clock library
Post by: rogerClark on Nov 03, 2014, 11:05 am
Hi Guys,

I've tried to integrate a RTClock library (from https://github.com/bubulindo/MapleRTC )from but I can't get it to compile yet.

I have nevertheless included the files inside libraries/RTClock and I have posted an issue to the author, to see if he/ she can advise

Basically the author's installation process requires the replacement of 2 of the core system files (rcc.c and rcc.h) with his replacements, however when I did this, even the bare minimum example would no longer compile, so I suspect that whatever he did to rcc.c and rcc.h is different from the way the later versions of rcc.c (and h) now operate.

Even if the author doesnt get back to me, I think its worth leaving the files in the libraries or perhaps move them to some other folder, as there are a lot of useful maple labs around, and its probably best if I can copy them all into my repo, in case someone else has a need for them and is willing to spend the time modifying them to work with this version of Maple/ STM32 code.
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 03, 2014, 11:14 am
I don't see why this is an issue.

The chinese manufacturers seem to have started to make Maple Mini clones (i.e that's what most people in this thread seem to be using). (Mine still have not turned up yet :-(


It means that I can't find the pin out of the mini! It would be good to dig it up and post it somewhere!
Title: Re: What's this I found on eBay?
Post by: Paul__B on Nov 03, 2014, 11:47 am
It does seem from the docs that the RTC may need calibration and the board I have doesn't look like it has a crystal, though it does have a black device marked:
8.000
103
(And some symbol to the right of the 103 that looks like a sawtooth)
Sounds awfully like a crystal to me!
(http://thumbs1.ebaystatic.com/d/l225/m/megiysuX4Jm1cnGposJ9I_A.jpg) (http://www.ebay.com.au/itm/NDK-CRYSTAL-SMD-8-000MHZ-3-2X2-5MM-NX5032GA-8-000000MHZ-/171524064412)
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 03, 2014, 01:14 pm
Ah that is the kiddy... but it is marked 8.000?

How odd given the chip can do 72MHz.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 03, 2014, 02:14 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Ah that is the kiddy... but it is marked 8.000?

How odd given the chip can do 72MHz.
Instead of a pre-scaler which would divide the clock, the STM32 uses a multiplier... you will note that 72.0 is an even multiple of 8.000

Quote
It means that I can't find the pin out of the mini! It would be good to dig it up and post it somewhere!
Well, since you are planning on reselling the units, I can understand that you would like to repost a PDF that did not point to an inexpensive Chinese source; however, the units I ordered points directly to the Leaflabs site - I can see no reason why you could not do the same?  (Especially if the silkscreening is the same!)
BAITE clones:
Maple Mini Clone (http://www.aliexpress.com/item/leaflabs-Leaf-maple-mini-ARM-STM32-compatibility/1400667476.html)

Quote
I had a look at Leaf labs website and it appears they are discontinuing the boards. I wonder if someone could persuade ST to look at funding getting the chip embedded into the Arduino platform...
While I am not at all annoyed by an enthusiast, I do get a little annoyed by a salesperson who just wants references so they can resell.  IN MY OPINION, if you have nothing technical to provide, please be quiet while Roger works through the issues.  You can then reuse whatever he creates.



Ray
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 03, 2014, 02:32 pm
Instead of a pre-scaler which would divide the clock, the STM32 uses a multiplier... you will note that 72.0 is an even multiple of 8.000

Well, since you are planning on reselling the units, I can understand that you would like to repost a PDF that did not point to an inexpensive Chinese source; however, the units I ordered points directly to the Leaflabs site - I can see no reason why you could not do the same?  (Especially if the silkscreening is the same!)
BAITE clones:
Maple Mini Clone (http://www.aliexpress.com/item/leaflabs-Leaf-maple-mini-ARM-STM32-compatibility/1400667476.html)

That link was down. (Specifically the one to the documents on the mini, I checked several times over the weekend and then found that the mini is no longer listed as a product on their website)

While I am not at all annoyed by an enthusiast, I do get a little annoyed by a salesperson who just wants references so they can resell.  IN MY OPINION, if you have nothing technical to provide, please be quiet while Roger works through the issues.  You can then reuse whatever he creates.

We are both enthusiasts and sales.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 03, 2014, 03:41 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Roger:

I pulled your latest repo from Github and tried it on my Maple mini clone from BAITE.  I cannot swear that the BAITE is identical to the original Mini, but the silkscreening does seem to match with the exception of av+ and av- which are now Vcc and Gnd. (adjacent to Vbat)


I overlayed my \hardware\maple-asp\Maple\cores & libraries & system & variants with your repo.  I retained Documents\Arduino\hardware\maple-asp\tools since I am using the SerialUSB functionality of the STM32 uC.

I then loaded GUI 1.5.7 and the Interactive Test sketch.  I inserted the USB cable into the Maple Mini and the board enumerated as COMx (12 on my Windows 8.1 64-bit system).  With the Tools\Board option set to Leaflabs Maple mini Rel2 to Flash and Tools\Port to COM12 I used the Upload icon to compile and upload.  Here is the console dialog:
Code: [Select]

Sketch uses 21,508 bytes (19%) of program storage space. Maximum is 108,000 bytes.
D:\Documents\Arduino\hardware\maple-asp/tools/win/maple_upload.bat COM12 1 1EAF:0003 C:\Users\WinUser\AppData\Local\Temp\build6424003391759384521.tmp/InteractiveTest.cpp.bin
maple_loader v0.1
Resetting to bootloader via DTR pulse
Searching for DFU device [1EAF:0003]...
Found it!

Opening USB Device 0x1eaf:0x0003...
Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=1, name="DFU Program FLASH 0x08005000"
Setting Configuration 1...
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
bytes_per_hash=570
Starting download: [##################################################] finished!
error resetting after download: usb_reset: could not reset device, win error: The system cannot find the file specified.

state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode

The error above appears to be non-critical... which is to say it always appear but the download goes well.

Opening Arduino's serial monitor and typing "?" the sketch starts a dialog:

Code: [Select]
Command Listing
?: print this menu
h: print this menu
w: print Hello World on all 3 USARTS
n: measure noise and do statistics
N: measure noise and do statistics with background stuff
a: show realtime ADC info
.: echo '.' until new input
u: print Hello World on USB
_: do as little as possible for a couple seconds (delay)
p: test all PWM channels sequentially
W: dump data as fast as possible on all 3 USARTS
U: dump data as fast as possible on USB
g: toggle GPIOs sequentially
G: toggle GPIOs at the same time
f: toggle pin 4 as fast as possible in bursts
r: monitor and print GPIO status changes
s: output a sweeping servo PWM on all PWM channels
m: output data on USART1 and USART3 with various rates
b: print information about the board.
+: test shield mode (for quality assurance testing)


Everything seems to work well.

Example output:
Quote
Taking ADC noise stats.
header: D3 n: 100 mean: 2079.02 variance: 4877.41
header: D4 n: 100 mean: 2090.56 variance: 3085.71
header: D5 n: 100 mean: 2091.37 variance: 3389.57
header: D6 n: 100 mean: 2112.17 variance: 9681.23
header: D7 n: 100 mean: 2106.56 variance: 6225.73
header: D8 n: 100 mean: 2104.35 variance: 6128.46
header: D9 n: 100 mean: 2107.72 variance: 8784.59
header: D10 n: 100 mean: 2086.04 variance: 6640.69
header: D11 n: 100 mean: 2090.18 variance: 3195.89
Added results from "b"
Quote
Board information
=================
* Clock speed (cycles/us): 72
* BOARD_LED_PIN: 33
* BOARD_BUTTON_PIN: 32
* GPIO information (BOARD_NR_GPIO_PINS = 34):
        ADC pins (9): 3, 4, 5, 6, 7, 8, 9, 10, 11
        PWM pins (12): 3, 4, 5, 8, 9, 10, 11, 15, 16, 25, 26, 27
        Used pins (4): 33, 32, 23, 24
At this point, I have not tested any of your code improvements in the system, but nothing done to date seems to affect the 1.5.7 compile and upload via serialUSB DTE kicking DFU mode.

Ray
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 03, 2014, 04:36 pm
The chinese manufacturers seem to have started to make Maple Mini clones
Im sure as long as people keep buying them then they will make them, perhaps with this 'sudden interest' in creating an Arduino shoe horn product, it may gain interest and snowball a little, unfortunately (as we have said before) this will be of no commercial interest to 'Arduino' UNLESS they take it on as a product option.. and that depends on popularity (amongst other factors), surely if most of the work is done for them (thanks to Roger et al) it would become a relatively simple addition.. although why would people buy an expensive Arduino version for $20 if they can buy a clone at a fraction of the cost ? hmmm

Personally, I FULLY intend to get something working with my dev board, and certainly move toward imbedding the STM32 into my own designs/pcbs etc

ROGER : Is there any possible option to go with the JTAG route ? or does that not fit the Arduino IDE format ? -  read the data sheet about the 'boot from system' so I believe there is a hardcoded bootloader in there somewhere, surely this cant be overwritten (I think you mentioned that before somewhere) ??

Regards Bob
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 03, 2014, 05:46 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
surely if most of the work is done for them (thanks to Roger et al) it would become a relatively simple addition.. although why would people buy an expensive Arduino version for $20 if they can buy a clone at a fraction of the cost ?
This has not seemed to be the case with the 1284P-PU (Bobduino.)  With 16K of SRAM the chip comes in at 2X the 2560 Mega SRAM but with less I/O.  The DIP also fits in with the concept fostered by the UNO of being able to easily replace the uC chip should it be damaged.  So, it appears that SRAM is not a fundamental driver in this corner of the Arduino 8-bit universe.

Additionally, Teensy 3.0/3.1 has great momentum in the $20 spot.  Paul has done wonders with the ARM chips in this class which run at 48MHz and 72MHz and are fully supported with his Arduino overlay package.
Teensy (https://www.pjrc.com/teensy/)

Based upon the link provided previously for the naked STM32 at 5 for $10, it seems that a fully built-out Chinese clone board for under $5 would be the better choice for most Arduino users wishing to play in these STM32 waters and those wanting to move to a higher quantity and margins could easily turn out their own boards for reflow.

I am holding my BAITE eBay board of which I secured 3 and I am seeing no quality issues whatsoever - even the stenciling is very good.  I have 5 more on order from Aliexpress (BAITE) and the are enroute according to the tracking information provided.  The point is, a $2 uC and a $1 board in quantity is great but most users are best served by the under $5 with free shipping.  I am sure some hobbyists will pay a premium for in-country faster delivery and that is great if they need fast gratification.

At this moment, it appears that even in this thread, there are two forks... one is the use of the serial ROM bootloader that is in the STM processor and one is the SerialUSB to DFU over the existing USB connector.  This is similar to the 32U4 Pro Micro and the 328P Pro Mini ... they both have a purpose.  So far, I am fully in the serial-to-DFU camp because it makes for a great prototyping environment, great high-speed console debugging, and absolutely no interference with project deployment.  I have bunches of USB to serial TTL adapters lying around, so I may try that approach at some time.  This fork is only an issue IMO until someone signs the USB and DFU drivers for Windows 7 and 8.  Until then, I'm just running my 64-bit Windows 8.1 installation in test mode... it is a development machine and frankly I don't really care about unsigned drivers - just another Microsoft ploy to make life more complex for all.


Ray

Title: Re: What's this I found on eBay?
Post by: westfw on Nov 03, 2014, 06:18 pm
Quote
I don't see why [leaflabs not making Maples] is an issue.
The chinese manufacturers seem to have started to make Maple Mini clones
Well, there's the standard "oshw clone problem."  Somewhere someone has to be making enough money to provide for "ongoing support" of the product.  And $5 clones from China won't do that.  People apparently weren't willing to buy enough $45 "original Maple" boards for Leaf Labs to do that.  I imagine Roger has a day job and isn't interested in chasing the Arduino modifications for the next 5 years, for free.  Or maintaining a separate web site.  ST has their own line of "Nucleo" boards and pushes their own software solutions, so they're probably not very interested. (and, BTW, those boards are pretty cheap too.)  The Arduino folk themselves already have a lot on their plate (and seem to be pretty "involved" with Atmel as a chip provider.)

No one really wants to spend 5x parts cost on something simple like an Arduino, but there's a good reason that that is a "rule of thumb" for electronics products pricing...
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 03, 2014, 11:16 pm
Guys...

(Just having to repost/ retype this whole reply because the reply I typed on my iPad did get seem to get posted by the new forum engine)

@mrbrunette

I've not changed the Maple uploader. I suspect the issue is not the board but possibly the vagueries of the Maple bootloader. I can't find it now, but I read something on the Maple forum about specifying a delay of 4000ms instead of 1000ms during the upload process, however this may be a feature that Maple put in their modified version of the IDE.

see http://forums.leaflabs.com/topic.php?id=74077 (http://forums.leaflabs.com/topic.php?id=74077)

Unfortunately my Maple clones have still not arrived (I checked the post every day last week hoping that something would arrive, but nothing did ;-(

@mcnobby

Re: JTAG

Theoretically JTAG upload should be possible.

The upload process from the IDE is simple (when you know how ;-)
There is a windows batch file that's called by the IDE, which is used to run the upload program, so it would be easy to add another board definition e.g. "ST32 upload via JTAG" which specified a different batch file e.f.  JTAG_upload.bat  which calls the external upload program for JTAG

ST themselves have a Windows JTAG upload program, that according to its doc's has a command line interface (CLI),
See   http://www.st.com/web/en/catalog/tools/PF258168# (http://www.st.com/web/en/catalog/tools/PF258168#)

So in theory JTAG_upload.bat could just call STLink.exe -c ......  etc 

Ideally whatever JTAG uploader was used would be open source as the ST exe could not be included as its license states "STMicroelectronics (ST) grants You a non-exclusive, worldwide, non-transferable"

The ST program installs drivers, but I'm not sure whose JTAG devices they are compatible with.

I did a quick search and someone has written some code to use an Arduino as a JTAG programmer, but as far as I could tell it only has some basic features and possibly not uploading.


I have a JTAG programmer (Chinese clone) on order from an eBay supplier - which I'm still waiting for (like a load of other eBay stuff). But when it arrives, I can let the forum know whether its a viable solution to uploading, even if you need to download and install the STLINK stuff
(i.e the STLINK stuff will probably always be installed in the same location, ie it installs in

C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility

So I could hard code this in the JTAG_upload.bat as it would work for most people

Actually it would be

 "%programfiles(x86)%\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe"



Re: Support by ST or the Arduino organization (company)

As @westfw has said. I think this is unlikely.
Firstly, the Arduino organization is effectively now a commercial company, ie it sells products and has a trademarked brand name, which is protected by law.

The STM32 boards are a competitor to their products (most directly to the arduino Zero when its finally released), so I can't see how its in their commercial interest to support it or help in any way.

BTW. Reading the thread on the New Forum, I get a distinct sense that there is a growing divide between the regular forum contributors e.g. @Robin2, and the forum operator e.g the Arduino organization, with the perception that the organization  placing little value on the community and generally focusing on developing new products under the Arduino brand.
(e.g. Goodness knows why their decided that they need to have an Arduino branded 3D printer, the reprap world has been using Arduino as the core of their open source printers for years)




Unfortunately I don't think these STM32 boards are ever going to appeal to the novice user who needs to be able to plug in a board and go (i.e everything just works straight out of the box with little or no programming or electronics experience required).

This is mainly because the Maple driver is not digitally signed, and 99% of people (me included) do not really want to have to boot their windows machine into a special mode in order to use the driver.
And even if you bypass the driver signing, it appears that the upload is intermittent (as experienced by @mrbrunette)

Additionally, at the moment, the API used by Maple is based on 0022 and also has a load of ST32 specific stuff. e.g. so that even a Serial.print("Hello world"); doesn't compile if I select any of the Maple board options, (because Maple chose to call their serial USB connection SerialUSB instead of Serial)


The software side of things could be fixed (eventually), e.g. I've already changed the files in my repo so that for anyone using Serial USB, that Serial is mapped to USART1 i.e the same one that the Serial USB needs to connect to in order to upload.
And I'm sure we (or I) could modify the core code so that SerialUSB gets mapped to "Serial" and just put defaults in for the other API stuff that I think needs to be called before using SerialUSB

Also all the other stuff like the SPI etc etc could be fixed in the core software (eventually) if there was enough community support.

But like @westfw said...   I have a day job, so this is only something I can do in my spare time, and I'm only doing it because I have a need to for a fast small processor with double precision floating point maths. (Actually I'm a freelance software developer, so what I do is up to me, but I can't give up paid work to do unpaid Arduino stuff)



To make this more mainstream, and get around the driver signing issues and general intermittent'ness of the upload. The board would need to have a separate microcontroller to handle the upload etc.
i.e I see that on the Due (I have 2 x Due's), that the Arduino designers found they need to include an ATMega16U2

The price of the 16U2 at low volumes however is around $5, ie the total price of the whole board !

So to be cost effective, the board would probably have to use another STM product e.g

http://www.aliexpress.com/item/STM32F103ZET6-STM32F103-LQFP144-ARM/32225968439.html

http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1031/LN1565/PF164495?sc=internet/mcu/product/164495.jsp

as these are only 35c !

But someone would need to modify the existing maple design, and also write the bootloader etc


i.e Its all do-able.

I could do it.... But it would take months to do for virtually no return, as the final board designs would need to be given away to the chinese manufacturers in order that there was the slightest hope of them being manufacturered cheaply.


I suppose there may be some middle ground, e.g. using an Arduino micro  etc as the programming tool, but there isn't that much benefit of this, over using Serial USB, except you don't need to press the reset button on the board before uploading ;-)

So I'm not convinced its worth the effort.

(BTW. I did try using a UNO as a USB to serial adaptor but couldnt get it to work, but I"m not entirely sure why.. Perhaps someone else could give it a go)


Anyway. Thanks for reading,  what has turned out to be a mini novel ;-)







Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 03, 2014, 11:26 pm
Interesting work Roger. under Linux the board I have comes up as a USB to serial converter, note quite like an Uno but it is there. I have not had a chance to play with it yet though. (I can see it as a serial port in the Arduino IDE)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 03, 2014, 11:27 pm
Anyway. Thanks for reading,  what has turned out to be a mini novel ;-)
As always Roger, very interesting and informative, I am ALL-EARS !!
Thanks for the JTAG info, I think I get the drift of the idea there :)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 03, 2014, 11:41 pm
@chilltronics

Quote
under Linux the board I have comes up as a USB to serial converter, note quite like an Uno but it is there. I have not had a chance to play with it yet though. (I can see it as a serial port in the Arduino IDE)
It should be possible to the python stm uploader

You will need to add tools folder to linux into the hardware and add a sh file I presume, (not looked at Linux builds recently)

However it should be possible

Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 03, 2014, 11:47 pm
Roger I will have a play...possibly later in the week.  Was there a particular brand you ordered?

Is the perceived problem that the Maple boards (and clones) don't have signed drivers for USB so for Windows a USB to serial converter is an answer? If so, surely they are commodity items?
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 04, 2014, 01:13 am
personally i dont understand why the maple USB firmware, on-board USB converters, and signed driver issues are even being discussed. these days boards like promini with no built-in USB outsell others that have one by an enormous margin. people are wising up. theres also the tendency for integrated interfaces and bootloader problems to account for the lions share of support posts.

on the other hand the mfg boot built into every chip appears to be 100% trouble free. silabs/ftdi drivers work with all os and converter cables cost less than a buck. im glad they are being supported in rogers package.

we all decide what to spend our time on but if i had the capability it would go toward getting library and ide routines polished instead of fighting to maintain an oddball interface. specially one thats rarely used in final setups.

anyway in view of recent comments on the two part numbers another set of c8t chips and bare breakout boards have been ordered. cant wait for this stuff to arrive. thanks again for all the hard work.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 04, 2014, 01:59 am
@chilltronics

You should be able to use a USB to Serial with the Maple mini

I've looked at the schematic and the Eagle board files and UART1 RX and TX appear to be on what are labeled as Pin31 and Pin30 (if your board follows the original design that Leaflabs put in github)

So if you attach USB to serial to those pins (obviously RX <--> TX etc between the USB to Serial and the Maple)

The put the device into Serial Boot mode. Which should be possible by holding down the "Button" (not the reset button, the other one....), the press and release the Reset button.

If you do that, the LED on the board should stop flashing, because it will no longer be running the bootloader, it should be using the Serial upload feature which is part of the hardware of the chip.


I've just tested the python serial upload from here https://github.com/jsnyder/stm32loader
and it does seem to work for me on the PC (Windows)

my batch file looks like this

Code: [Select]
cd %~dp0
rem: the two line below are needed to fix path issues with incorrect slashes before the bin file name
set str=%4
set str=%str:/=\%
rem stm32flash -g 0x8000000 -b 230400 -w %str% %1
C:\Python27\python.exe stm32loader.py -e -w -p %1 -b 230400  %str%


i.e I rem'ed out the stm32flash windows exe and used python

One issue I had with this, when I just tried it, was that there wasnt a command to run after upload, but when I looked in the python code, the author had already put in code to do this but not to be able to use the code.

So I've make a modified version which has an addition option of -g (for go) which runs from the upload address (which is defaulted to 0x800000 - i.e start of Flash for most of these devices)


I have attached the revised python file, and I will upload it to my github repo when I get chance.

If you managed to get it working on linux, please let me know and post the tools folder etc and whatever scripts you had to change.

Thanks

Roger

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 04, 2014, 02:01 am
aargggghh

The forum didnt accept python files ??????


Hopefully it will accept zips

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 04, 2014, 02:04 am
@john1993

Quote
personally i dont understand why the maple USB firmware, on-board USB converters, and signed driver issues are even being discussed. these days boards like promini with no built-in USB outsell others that have one by an enormous margin. people are wising up. theres also the tendency for integrated interfaces and bootloader problems to account for the lions share of support posts.
I totally agree, but it seems like a lot of people who are interested in the Maple board seem to still be trying to use it via its USB connection.

I'm just treating my generic STM32 board, as if it was a pro mini, and I'm manually resetting it, which works absolutely fine for me, and I'm pretty sure would work fine for anyone with a Maple Mini

Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 04, 2014, 02:39 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
I totally agree, but it seems like a lot of people who are interested in the Maple board seem to still be trying to use it via its USB connection.
So, IMO, it is like a Pro Micro... The LUFA code in the boot loader works and the USB personality changes.  Even I have some issues from time to time with these little 32U4 boards but I mainly use the serialUSB for debug info while programming or in one design as an optional log.text stream to the PC.  The code and h/w is on the board, might as well use it.  Of course, I could take the approach of using a $1 USB to serial, reflash the 32U4 with a serial boot loader, and just pretend it is a Pro Mini with an extra 0.5K SRAM!

roger  is doing a great job and I much appreciate his effort, but since the USB is already on the board and since I have it generally working under 1.5.7, I am just pretending this is a Pro Micro... No need to forget about the USB.  But, for others please feel free to go in any direction you choose - I speak only for myself.  As far as wasting any cycles, I do not believe roger has done much in this area although I have mentioned it in several posts, but mainly just statusing where I was with my effort and testing.  To recap, I can consistently download to flash in the STM32 from 1.5.7 and I can consistently use TeraTerm or Arduino monitor to display the COMx port and even do interactive dialog.  What does not work is an attempt to use the SerialUSB after downloading to SRAM... Windows does not enumerate the COMx port.  I am using Win8.1 Professional in 64-bit and the workstation is in test mode so I can run unsigned drivers - test mode is persistent through power cycling or reboots.

It is my opinion that this will never be ready for mainstream newbie use, but for the more teckie of the forum, it is a great 32-bit speed option: small, 3.3V and full clock speed at 3.3V, and pretty cheap.

I have received an email from Aliexpress - a tracking number has been assigned and the 5 boards are in transit.
Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 04, 2014, 03:32 am
Hi Ray,

Quote
since the USB is already on the board and since I have it generally working under 1.5.7, I am just pretending this is a Pro Micro.
No worries. I tried not to do anything that would break the existing functionality for people that want to use the on board USB.



I think it could be interesting to see if it was possible to add USB support to the non-bootloader build
Currently I think the USB code is in the bootloader and is called from the uploaded code - because if I attach the board via USB after having uploaded a non-bootloader example e.g blink, the device appears on USB but doesnt have any VID

I can see code for it here

https://github.com/RavWin/RHIDDemo

but currently I don't have time to compile it.

But its still food for thought

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 04, 2014, 03:34 am
i agree having two methods of downloading is better than one. three is even better. apparently you can pick up an stlink programmer for about the same cost as a usbasp and it works about the same way. direct isp flashing. so this just keeps looking better and better.

i dont see why this would not be for beginners though. it looks like roger is dressing this up like atmel based arduino... install and download. it cant get much noobier than that.

when this started i checked out some of the normal arm procedures... total opposite end of the spectrum. what a nightmare.
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 04, 2014, 04:27 am
Quote
IMO, it is like a Pro Micro... The LUFA code in the boot loader works and the USB personality changes.
Yes.  But be careful not to confuse your "Pro Micro" and "Micro" (32u4-based) with the "Pro Mini" (328 based, widely cloned at ridiculously low prices.)

It will have all the "re-enumeration" problems during reset/boot as Leonardo, plus whatever is introduced by the Maple code.  It's a shame that Leonardo came out after Leaf Labs was "done" - there would be benefit in unifying the way the bootloaders/autoreset works...
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 04, 2014, 04:40 am
@westfw
Quote
It will have all the "re-enumeration" problems during reset/boot as Leonardo
+1

I have some Arduino Micro's and find them a pain to work with, as the re-enumeration often screws up or they keep changing comm port number over and over again.

I not from the forum, that I'm not alone, and most of the forum elders don't recommend newbie's use the Leonardo for the same reason.

IMHO if you want a small Arduino with built in USB then the Nanoe is probably the best bet as its rock solid.

Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 04, 2014, 05:22 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
i dont see why this would not be for beginners though. it looks like roger is dressing this up like atmel based arduino... install and download. it cant get much noobier than that.
I work newbie questions often and that is with products like UNO.  Imagine the newbie support requirements for nonofficial product that use a different compiler, different libraries, and different hardware... It is always one-off.  Say Adafruit puts out a library for a new sensor... There is little incentative for Ladyada to code for STM32.  But let a newbie with a Maple clone buy one of those sensors and they are going to be on the forum begging for help!

Just read the newbie posts on tiny85 or board-duino... It is amazing how much trouble can be created and these two groups are very well documented in the forum and on the internet generally.

But, I have been wrong before  :o


Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 04, 2014, 07:49 am
Guys

FYI.  Wire seems to be broken at the moment. I'm not to sure which change has caused this.

I did have a basic Wire test program working with a BMP085 barometer, but now the code crashes somewhere in Adafruits library :-(

I'll need to go back to a previous version that I put in GitHub and try to figure which change broke it :-(
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 04, 2014, 09:02 am
Quote
It does seem from the docs that the RTC may need calibration and the board I have doesn't look like it has a crystal, though it does have a black device marked:  8.000
The RTC on the STM32F1xx chips has a separate crystal oscillator optimized for a low-freq (32768Hz) "watch crystal."   Some of the cheap development boards already have this crystal populated (having who-knows-what effect on those pins if you don't use it!)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 04, 2014, 09:09 am
Just read the newbie posts on tiny85 or board-duino... It is amazing how much trouble can be created and these two groups are very well documented in the forum and on the internet generally.
I know this very well, I have been doing alot with t85, and more recently testing out the new t13 core which seems pretty stable now

This has probably been said but if this becomes a newbie device I fear there will be screams of 'Help Roger, HELP !!' all over the forum

Perhaps once this is all finalised there could be a 'How To STM32' thread started listing what to do, or just a reference to Rogers Blog ?

There is a lot of awesome info in this thread, but one would have to read all 15 pages to be fully up to speed

:)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 04, 2014, 09:14 am
I will be trying my 'half-way house' solution this weekend - ATMega1284 running at 32mhz

Well I say halfway house, its more 1/8 house comparing clock speed and 8 vs 32 bit math !!
Title: Wire not broken ;-)
Post by: rogerClark on Nov 04, 2014, 11:21 am
Guys,

I know I said in my other post that Wire was broken,  well after a lot of messing around going back through old versions I commit to GitHub, I tracked down when the problem occured, and it was when I changed the code to assign Serial to UART1 and Serial1 to UART2

Anyway, looking at where it was crashing, I realised that I'd modified the Adafruit BMP085 library to #define Serial to Serial1 inside the lib before I made the change to the core code.

And I had not removed this temporary hack

So the #define Serial Serial1 was going something very bad, and the first call to Serial.print() was causing the whole thing to hang.

I'm not entirely sure quite why it would cause a hang / crash but it did

Anyway. Panic over, the latest version is fine and Wire is working


I have however found one issue in my development process. I seem to have somehow screwed up my local git repo, and I'm unable to switch branches :-(

So I may need to bin the whole repo in GitHub and start a new one, if I can't sort out why my local repo is misbehaving. 
I suspect the problem is because I dual boot to PC and other OS's which keep changing the RTC in my PC from UTC to local time of UTC + 11, which really seems to screw some things up, if I don't notice it when its running Windows, and change the time accordingly

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 04, 2014, 11:58 am
having who-knows-what effect on those pins if you don't use it!
crystals have virtually no effect on pins they are wired to. essentially 5-10pf caps. i.e. "not there".

its a shame the original promini designers didnt realize this and failed to bring out those pins. 99% of my projects have no need for 16mhz but could really use the extra io. another thing besides the ridiculous pin duplication and arrangement those morons at sparkfun botched.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 04, 2014, 02:17 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


@westfw
+1

I have some Arduino Micro's and find them a pain to work with, as the re-enumeration often screws up or they keep changing comm port number over and over again.
<...>
I must be the only person in the world that does not have USB enumeration problems, in general.  Other than having been a MCSE in a prior life and understanding perhaps a weebit more than joe-street, I also keep my unused (hidden) USB tree pruned regularly... meaning I delete unused USB enumerations often. Additionally, I have my own USB VID/PID pair for those situations where I am testing my own stuff.

Written for XP, this article explains the process for XP, Win7/8/8.1:
kb/315539 (http://support.microsoft.com/kb/315539)

Just DO NOT delete the drivers!  You want them around for/IF the device is ever in need of those again.  Regular pruning really helps to avoid USB driver constipation  :D


Ray
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 04, 2014, 02:28 pm
I must be the only person in the world that does not have USB enumeration problems
probably not the case. rumor has it that there are at least 3 other individuals out there with same good luck. iirc one in china and two are russian. main problem is not every one has access to that "pair" and "prune" the tree.

seriously though, thanks for that link. its bookmarked and hopefully will come in handy next time those problems "crop" up.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 04, 2014, 06:51 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
one in china and two are russian. main problem is not every one has access to that "pair" and "prune" the tree.
:D

My fear of being the only one is quenched.  Thank you!

Ray


PS: a very inexpensive way to get a VID/PID for home/hobby efforts:
VID / PID for V-USB experiments (http://www.obdev.at/products/vusb/license.html)
In contemplating this, remember that V-USB is Trinket, Digispark, V-USB on Arduino, etc.  I have a few off the wall projects here: Ray's Projects (http://www.hackster.io/rayburne)

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 04, 2014, 07:03 pm
PS: a very inexpensive way to get a VID/PID for home/hobby efforts:
I was just reading this a couple of days ago, looks pretty good although I havent used it yet :)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 04, 2014, 07:07 pm
Is this the kind of JTAG programmer that I could use ? (never having used it before I dont actually know if there are any differences)

http://www.ebay.co.uk/itm/New-Mini-USB-Blaster-ALTERA-Cable-for-FPGA-NIOS-10-Pin-JTAG-Altera-Programmer-/221587427089?pt=LH_DefaultDomain_3&hash=item3397a3cf11 (http://www.ebay.co.uk/itm/New-Mini-USB-Blaster-ALTERA-Cable-for-FPGA-NIOS-10-Pin-JTAG-Altera-Programmer-/221587427089?pt=LH_DefaultDomain_3&hash=item3397a3cf11)
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 04, 2014, 08:24 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Simple test of SPI2:  Polling SPI loopback test

Using TeraTerm over SerialUSB. 
Using Windows 8.1 64-bit (all patches)
Using Arduino 1.5.7
Using rogerClark's github image from 31/10/2014


Code: [Select]

** Having a conversation, MSB first
Having a chat.  Frequency: 140.625 KHz, bitOrder: MSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 140.625 KHz, bitOrder: MSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 140.625 KHz, bitOrder: MSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 140.625 KHz, bitOrder: MSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 281.250 KHz, bitOrder: MSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 281.250 KHz, bitOrder: MSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 281.250 KHz, bitOrder: MSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 281.250 KHz, bitOrder: MSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 562.500 KHz, bitOrder: MSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 562.500 KHz, bitOrder: MSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 562.500 KHz, bitOrder: MSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 562.500 KHz, bitOrder: MSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 1.125 MHz,   bitOrder: MSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 1.125 MHz,   bitOrder: MSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 1.125 MHz,   bitOrder: MSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 1.125 MHz,   bitOrder: MSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 2.25 MHZ,    bitOrder: MSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 2.25 MHZ,    bitOrder: MSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 2.25 MHZ,    bitOrder: MSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 2.25 MHZ,    bitOrder: MSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 4.5 MHz,     bitOrder: MSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 4.5 MHz,     bitOrder: MSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 4.5 MHz,     bitOrder: MSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 4.5 MHz,     bitOrder: MSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 9 MHz,       bitOrder: MSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 9 MHz,       bitOrder: MSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 9 MHz,       bitOrder: MSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 9 MHz,       bitOrder: MSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 18 MHz,      bitOrder: MSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 18 MHz,      bitOrder: MSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 18 MHz,      bitOrder: MSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 18 MHz,      bitOrder: MSB,  mode: 3. [1]  [2]  [3]  ok.
** Having a conversation, LSB first
Having a chat.  Frequency: 140.625 KHz, bitOrder: LSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 140.625 KHz, bitOrder: LSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 140.625 KHz, bitOrder: LSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 140.625 KHz, bitOrder: LSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 281.250 KHz, bitOrder: LSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 281.250 KHz, bitOrder: LSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 281.250 KHz, bitOrder: LSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 281.250 KHz, bitOrder: LSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 562.500 KHz, bitOrder: LSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 562.500 KHz, bitOrder: LSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 562.500 KHz, bitOrder: LSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 562.500 KHz, bitOrder: LSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 1.125 MHz,   bitOrder: LSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 1.125 MHz,   bitOrder: LSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 1.125 MHz,   bitOrder: LSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 1.125 MHz,   bitOrder: LSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 2.25 MHZ,    bitOrder: LSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 2.25 MHZ,    bitOrder: LSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 2.25 MHZ,    bitOrder: LSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 2.25 MHZ,    bitOrder: LSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 4.5 MHz,     bitOrder: LSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 4.5 MHz,     bitOrder: LSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 4.5 MHz,     bitOrder: LSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 4.5 MHz,     bitOrder: LSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 9 MHz,       bitOrder: LSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 9 MHz,       bitOrder: LSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 9 MHz,       bitOrder: LSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 9 MHz,       bitOrder: LSB,  mode: 3. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 18 MHz,      bitOrder: LSB,  mode: 0. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 18 MHz,      bitOrder: LSB,  mode: 1. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 18 MHz,      bitOrder: LSB,  mode: 2. [1]  [2]  [3]  ok.
Having a chat.  Frequency: 18 MHz,      bitOrder: LSB,  mode: 3. [1]  [2]  [3]  ok.

*** All done!  It looks like everything worked.



Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 04, 2014, 08:40 pm
@mcnobby

I ordered one of these a few weeks ago

http://www.ebay.co.uk/itm/ARM-Emulator-ARM11-ARM9-ARM7-Cortex-M3-J-link-V8-ADS-IAR-STM32-JTAG-New-dhi-/311094686394?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item486eb032ba

So I will let the forum know if it works, if and when it finally arrives.
( I seem to be having very long delivery times from ebay china at the moment, 5 weeks and counting on that JTAG and another STM32 board. Things i order days or weeks apart seem to all arrive together on the same day. I think I may try to find alternative sources, as more than 4 weeks delivery time is becoming impractical. I may try sourcing from Singapore etc, but not china or Hong Kong)
Title: Another Lib Maple fork
Post by: rogerClark on Nov 04, 2014, 08:45 pm
Guys

I found this Lib Maple fork while reading old postings on the Maple forum

https://github.com/rambutan32/librambutan

I'm not too sure what the purpose is, except possibly to maintain or bug fix lib maple now that leaflabs no longer support lib maple

I will contact the author and possibly do some sort of merged build if it looks beneficial,
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 04, 2014, 09:09 pm
Ray

Re: leonardo re enumeration etc

It seems quite random whether it is a pain or not. I have multiple machines and they all behave differently, but I suppose that's because they all have different sets of USB drivers on them, depending on what I have plugged into them etc

Re: vusb

Sounds very interesting.

$9.99 for hobby use seems a great price, I may invest in that today.
$199.99 for commercial is also a pretty good deal for a small company.


I've not read the whole site, so I'm not too sure how the driver signing can happen, but its worth looking into


Re SPI

Thanks

I can't view the ino on my ipad, but I presume you are using the HardwareSpi directly, in the longer term I was hoping to make a wrapper so existing arduino spi sketches would compile.


BTW.
with Wire.  There are 2 things to be aware of.
1. I defaulted the pins used to the Hardware I2c channel pins even though its currently bit banged and could run on any pins. This is probably not the default for Maple who seemed to have them on some non I2C hardware channel pins.
From memory I think I put them on pb6 and pb7, look in the bottom of wire.cpp

However it seems that for me Sck and SDA are the wrong way around. Ie in lib maple constructor for the twowire class it documents them one way around, but to get it to work with my barometer I had to swap the wires.

I need to investigate this further to see quite why I need to do this

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 04, 2014, 10:35 pm
Just because I was getting fed up with none of my other STM32 boards turning up, I've ordered a different one (but again from an eBay seller)

http://www.ebay.com/itm/281368569498 (http://www.ebay.com/itm/281368569498)

Interesting bits in the blurb are

- STM32F103RC, with 51* GPIO/ 256K Flash / 48K SRAM
- Onboard RTC battery, offer MCU power off maintain and backup

(http://www.goodluckbuy.com/images/ebay_gadgetinfinite_images/sku_104818_3.jpg)

RTC battery appears to be on the back

(http://www.goodluckbuy.com/images/ebay_gadgetinfinite_images/sku_104818_2.jpg)


Full spec on STM's site is below. Note, this is the RC version with 256k flash and 48k RAM not the bigger R8 version. I'm not sure how else it differs from the STM32F103Cxx devices, but it will be interesting to see it is compatible. I will need to make a new board definition for Flash size etc, but apart from that I suspect it should basically work.



Key Features

   Core: ARM 32-bit Cortex™-M3 CPU
   72 MHz maximum frequency, 1.25 DMIPS/MHz (Dhrystone 2.1) performance at 0 wait state memory access
   Single-cycle multiplication and hardware division
   Memories
   256 to 512 Kbytes of Flash memory
   up to 64 Kbytes of SRAM
   Flexible static memory controller with 4 Chip Select. Supports Compact Flash, SRAM, PSRAM, NOR and NAND memories
   LCD parallel interface, 8080/6800 modes
   Clock, reset and supply management
   2.0 to 3.6 V application supply and I/Os
   POR, PDR, and programmable voltage detector (PVD)
   4-to-16 MHz crystal oscillator
   Internal 8 MHz factory-trimmed RC
   Internal 40 kHz RC with calibration
   32 kHz oscillator for RTC with calibration
   Low power
   Sleep, Stop and Standby modes
   VBAT supply for RTC and backup registers
   3 × 12-bit, 1 μs A/D converters (up to 21 channels)
   Conversion range: 0 to 3.6 V
   Triple-sample and hold capability
   Temperature sensor
   2 × 12-bit D/A converters
   DMA: 12-channel DMA controller
   Supported peripherals: timers, ADCs, DAC, SDIO, I2Ss, SPIs, I2Cs and USARTs
   Debug mode
   Serial wire debug (SWD) & JTAG interfaces
   Cortex-M3 Embedded Trace Macrocell™
   Up to 112 fast I/O ports
   51/80/112 I/Os, all mappable on 16 external interrupt vectors and almost all 5 V-tolerant
   Up to 11 timers
   Up to four 16-bit timers, each with up to 4 IC/OC/PWM or pulse counter and quadrature (incremental) encoder input
   2 × 16-bit motor control PWM timers with dead-time generation and emergency stop
   2 × watchdog timers (Independent and Window)
   SysTick timer: a 24-bit downcounter
   2 × 16-bit basic timers to drive the DAC
   Up to 13 communication interfaces
   Up to 2 × I2C interfaces (SMBus/PMBus)
   Up to 5 USARTs (ISO 7816 interface, LIN, IrDA capability, modem control)
   Up to 3 SPIs (18 Mbit/s), 2 with I2S interface multiplexed
   CAN interface (2.0B Active)
   USB 2.0 full speed interface
   SDIO interface
   CRC calculation unit, 96-bit unique ID
   ECOPACK®packages


Edit. I just did a quick compare of features, and it has a few more capabilities than the CB/C8 variants, and generally greater numbers of the peripherals in the CB/C8 e.f. more I2C's (not that more than one is normally needed)
It does seem to have better external support for memory and has SDIO

Of course writing libs for all this stuff is what would take the time and effort.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 04, 2014, 11:03 pm
Up to 112 fast I/O ports... 51/80/112 I/Os, all mappable on 16 external interrupt vectors and almost all 5 V-tolerant
 
Do you think it may be russian roulette to find the ones that arent ? ;)

Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 04, 2014, 11:08 pm
Do you think it may be russian roulette to find the ones that arent ? ;)


Well, it's either that or read the data sheet... ;)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 05, 2014, 12:05 am
@mcnobby

The same text

Quote
and almost all 5 V-tolerant
Appears for the STM32F103CB used in the Maple Mini

And like ChilliTonrix said, reading the data sheet is probably a good idea ;-)


However, It would be easier if ST just listed the pins that were not 5V tolerant.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 05, 2014, 12:09 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
I can't view the ino on my ipad
Ah, I use ES File Explorer on Android 4.4.4 Nexus.  I think they do iOS, too.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 05, 2014, 12:40 am
Hi Ray,

I jailbroke my iPad but I think that the browsers have a hard coded list of files that they will download.

If I can download it, I can view it as I have several document viewers and also iFile which is a bit like ESS on Android

(I have Android devices as well, which are newer than my old iPad, but it seems to be that I'm the one relegated to the old hardware ;-)

PS. Is notifications via emial working for you. It did work for a while on this new "improved" forum version, but I've not got any for around a week, so I find it hard to keep track of replies
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 05, 2014, 12:40 am
Just posting again, to try to reset my notifications settings.

Edit. Just tried ticking all the boxes in the notification settings. Lets hope that works.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 05, 2014, 12:44 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Guys

I found this Lib Maple fork while reading old postings on the Maple forum

https://github.com/rambutan32/librambutan

I'm not too sure what the purpose is, except possibly to maintain or bug fix lib maple now that leaflabs no longer support lib maple

I will contact the author and possibly do some sort of merged build if it looks beneficial,
Very interesting...
Quote
Wirish

Wire I2C library: New, improved, and more Arduino-compatible Wire library, thanks to Trystan Jones.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 05, 2014, 12:55 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
PS. Is notifications via emial working for you. It did work for a while on this new "improved" forum version, but I've not got any for around a week, so I find it hard to keep track of replies
roger,

No, not working... I just gave up and disabled it.  Unread Posts are kind of working... But I have just been reviewing my 'latest posts' to stay on track a little.

The link to librambutan is intriguing ... Thanks for posting.

Quote
(I have Android devices as well, which are newer than my old iPad, but it seems to be that I'm the one relegated to the old hardware ;-)
The Nexus is MINE


Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 05, 2014, 01:23 am
Thanks Ray,

I thought perhaps it was just my settings, as it packed up, then notifications started working on some threads but not all, and now I'm not getting anything at all.

Don't get me started on the new forum ;-)
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 05, 2014, 02:03 am
Quote
It would be easier if ST just listed the pins that were not 5V tolerant.
I included that in my spreadsheet here: STM32F103c8 pinout GoogleDoc (https://docs.google.com/spreadsheet/ccc?key=0AqdMB5dovDUZdGR6cVprUnkwTV9CMUNybV9VMjF5a0E&usp=sharing)

I highly recommend making one of these for any chip that you use "seriously", if you can't find one that already exists.  Highly educational!
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 05, 2014, 03:31 am
@westfw

Thanks.

Very informative
Title: eBay delivery times
Post by: rogerClark on Nov 05, 2014, 04:03 am
@mcnobby

Re: That JTAG you linked to.

Looking at the description, it specifically mentions Altera devices, so althought it's very cheap, I think the chances of getting it to work with STM is a lot lower than the one I have on order, which specifically states STM in the listing.

I guess you could buy one and see if you can get it to work, and let us know, but I'd do it with the expetation that the chances are that its not going to work.




Also... (everyone)

Just a heads up regarding delivery time on some of these STM boards and other related stuff.

I just checked my eBay purchase history to see exactly when I ordered the JTAG programmer and when the expected deliver was, and I hadn't realized that the supplier had marked the delivery has taking between 6 and 8 weeks !!!

I will need to check this in future, as I normally expect 3 to 4 weeks, sometimes less, but in that sort of ball park, but 6 to 8 weeks, is definitely stretching this a bit too much for me.


I double checked and they had specific 5 to 6  weeks delivery time (still more than I'd realized)

I suspect however that although I'm closer to china than for example people in the UK, (as I'm in Australia), things may take longer to get here as the suppliers can possibly opt for surface mail which could still get here (on a boat) in a few weeks.

Where as for Europe and possibly the US, the surface mail (boat) times are likely to be at least 6 weeks in some cases, just because that's how long it takes to sail half way around the world.

Hence suppliers have to opt for air mail, because no one will accept 6 to 8 weeks or possibly longer

Anyway, I will be more observant of this in the future ;-(
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 05, 2014, 08:19 am
Re: That JTAG you linked to....
I guess you could buy one and see if you can get it to work, and let us know, but I'd do it with the expetation that the chances are that its not going to work.

I think I will do that Roger, its only pocket money prices, what is the worst that can happen ?? ;)


RE: delivery from China

I think the whole world suffers similarily, although I have got items from china in 8 days, items that cost £0.99p with FREE delivery - how the hell do they do that ???

:)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 05, 2014, 09:33 am
Quote
I have got items from china in 8 days, items that cost £0.99p with FREE delivery - how the hell do they do that ???
I had the same thought.

I think that somehow they must get free postage and get the product even cheaper than 99p.

There were a couple of interesting articles on the web from the guy that runs Freetronics (who make various arduino derivatives), about going to china to see the tech markets etc, e.g. literally street markets and warehouse style markets selling all this sort of stuff at knock down prices.

Looking at some of the other things I've bought from AliExpress, (specifically a Serial Wifi module), when I reset it back to factory settings it was clear it had come from a factory which was producing them for a consumer product, and it looks like somehow they were making it out the back door (so to speak) and then down to the markets, but in between, someone was changing the settings to disguise its original purpose.

These maple boards were obviously produced by some enterpising company for hobbiests, but I looked at a lot of other STM32 boards on AliExpress, (there must be at least 25 different types of STM32FXXX boards for sale), and I strongly suspect they were all off the production lines of commercial products. No idea what, possibly washing machine controllers etc (but they were probably too high spec washing machines)




I also noticed that ST seems to use the word Arduino for its Nucleo  board (which is actually a nice looking board)

But its only link to Arduino is pin headers that fit Arduino shields

In the longer term I think I may get a Nucleo  board, as they really cool !
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 05, 2014, 04:10 pm
I think that somehow they must get free postage and get the product even cheaper than 99p.
The delivery times started to fool me a bit, then I wondered if they hold back on sending out consignments until they have a certain weight/quantity which they can get shipped for a specific 'all-in' cost, that would answer the variable delivery times question I guess, but how they send it for next to nothin I will never know.. If I tried to send what they sent me across the UK it would cost me more than 99p !!!


I also noticed that ST seems to use the word Arduino for its Nucleo  board (which is actually a nice looking board)...In the longer term I think I may get a Nucleo  board, as they really cool !
I saw some in very nice vacuum moulded packaging.. I really like them but I already have far too many dev boards [you can never have TOO many dev boards !!!] ;)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 05, 2014, 04:15 pm
Just looking at the (very reasonably priced for UK) NUCLEO boards on Ebay, there seems to be quite a few variants.. and I wouldnt know which one to go for, if I was to go for one, assuming I want one, which I obviously do, and can afford one, but really dont have the time for more 'play-time' ..... kid in sweetshop syndrome !
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 05, 2014, 04:26 pm
I reckon THIS ONE (http://www.ebay.co.uk/itm/Nucleo-STM32F1-DISCOVERY-STM32F103-STM32-ARM-Cortex-M3-Development-Board-Arduino-/161356505065?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item259198dfe9) is similar to the ones we have been discussing - not sure exactly what the differences are.. its a LQFP64 rather than the LFQP48 of the STM32F103CBT6, still 128k flash though
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 05, 2014, 04:31 pm
I was just having a goooogle round, and found this...

http://arttools.blogspot.co.uk/2009/09/using-stm32-based-board-for-arduino.htmll (http://arttools.blogspot.co.uk/2009/09/using-stm32-based-board-for-arduino.html)

.. not sure if its relevant, or helpful though
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 05, 2014, 04:48 pm
RE : JTAG stm32 jtag programmer...

I also found this...

http://www.ebay.co.uk/itm/ST-Link-V2-Mini-Metal-Shell-STM8-STM32-Emulator-Downloader-Programming-Unit-/271601614389?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item3f3cb7be35 (http://www.ebay.co.uk/itm/ST-Link-V2-Mini-Metal-Shell-STM8-STM32-Emulator-Downloader-Programming-Unit-/271601614389?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item3f3cb7be35)

.. rediculously cheap !!
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 05, 2014, 09:10 pm
@mcnobby

Re: ST Link clone

That one looks more likely to work than the  Altera one.

ST Link is STs programmer and you can download the software from STs site for it.


Re The other maple IDE clone / branch

Wow, another one.  The more we look the more maple IDE derivatives we find.
The main issue with that one is that the GitHub repo has not been updated in 5 years, and the Arduino core API has changed bit since then.

However there may be some code snippets that we could use.

Also the author wrote some sort of uploader and posted the code, which may be useful, albeit I think the board is something different again, its an ET STAMP STM32

I've taken a quick look, and as far as I can tell, this board just has USB to serial for uploading, I presume its connect to USART.


I found other articles on uploading including a list of uploaders

http://www.micromouseonline.com/2009/05/08/stm32-arm-cortex-bootloader/

However in that article they didn't realise that its possible to run the code without switching the links back

Searching for other stuff I also found this

http://armstrap.org/

Which adafruit will manufacture

However it looks expensive, and something a lot different to using these cost effective stm32f103 boards with arduino



Title: Not much progress with I2Cdev library
Post by: rogerClark on Nov 05, 2014, 09:18 pm
After I fixed my issues were I broke the adafruit bmp085 barometer library, I've taken another look at hooking up a MPU9150 motion sensor.

However the libs for this use I2Cdev which is a library that directly calls functions that Wire calls, I.e is kinda a replacement for Wire, but you still seem to need to call wire begin.

Anyway, the normal avr i2cdev won't compile, but I found a version that someone had modified for maple, which does compile.

But at the moment, I can't get it to communicate with the MPU9150

Looking at the SDA and Scl lines with a scope, there is data traffic, but I'm not sure what direction it's going.
Possibly all outbound.

So my next step is to put debug code into the MPU9159 lib or possibly even into i2cdev to figure out why the lib says nothing is connected.

I will keep the forum posted.

Edit.

I've given up with the version of I2CDev that someone had modified for Maple, as I've no idea what they changed

I think its better to get Wire working for the normal I2CDev

I found one issue so far, Wire.h now defines BUFFER_LENGTH which is not in the old Maple version of Wire that I'm using

However although it appears to be writing data to the I2C lines, when it reads back it just gets zeros :-(

I think I may need to look at writing a library for BMP085 that uses I2C rather than Wire calls driectly (as the adafruit one does)

As I know my BMP085 is working, on STM32, so getting I2CDev working in a basic fashion with that device would rule out hardware e.g bus timing issues that may be occuring using the MPU9150


However thats probably all I'm going to manage today.

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 05, 2014, 10:53 pm
i would love to see that arduino scanner demo work. theres a lot of i2c parts kicking around here including mems compasses, gyros, and accelerometers and many different 24xx ee. it would be wonderful to see some sign of life there with this arm board.

personally i like the bit bang approach because not only does it allow just about any pins but makes porting to wildly different mcus easy. im not a big fan of peculiar built-in peripherals unless theres a major advantage to using them which does not seem to be the case with i2c. so many variations of spi thats usually better off banged too imo.
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 05, 2014, 11:05 pm
Whilst the bit banging approach works and is portable, doesn't it also consume more RAM and CPU cycles than the dedicated hardware?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 06, 2014, 12:05 am
I2CScanner sketch isnt working at the moment.

The problem is that Wire.end in Maple (wire.cpp) always returns SUCCESS  which is not what the Wire.cpp now does in Arduino 1.0 onwards

I didn't take a look to see what would need to be changed to fix this, but I doubt it would be that hard.


Wire does seem to work with some things; well it works with the Adafruit BMP085 library (now that I updated wire to use the Arduino 1.0 function names of read() and write() rather than receive() and send()

However that's as far as I got.

I had thought about hooking up an I2C display that I have, (its an OLED one), but I will have to test which of my displays actually works, as I bought several of them from eBay and only one size of display actually works with the Adafruit library.

I can see that with the larger display (1.3 inch) that it kinda works, but something is screwed up with width and height etc as I just get random patterns of lines.

So I'd need to get one of those displays working with a Uno, and when I know for sure its OK and I have a lib that works for it, then try it on the STM32


@ChilliTronix

I totally agree. This bit-banging solution is far from ideal. However at least for the moment there is some way to use I2C on these devices, and that will encourage other people to be interested.


Strangely, from what i recall, Maple chose to use pins for I2C that are not on a hardware I2C channel.

But I changed this in my repo so that I'm using PB6 and PB7 (I've no idea what pins Maple call them, there mapping scheme doesnt make much sense to me)
So that when Hardware I2C is sorted out, I'lll not need to re-wire anything.

ST have example code for hardware I2C but their code is non-distributable, so a re-write would need to be done.

However (not that I would ever do this ;-)  But I just changing the var names and re-arranging the code a bit is basically all that a re-write would look like ;-)
As fundamentally if ST's code is the way it has to be done, there are few other ways to do it.

Especially as there are "Erratica" in the silicon of the chip (i,e ST have an application note full of work arounds for bugs in the silicon !), which require things to be done in a specific way in order for them to work. i.e this could include I2C (I've not looked in detail)



Edit.

I just looked at the Maple Wire.cpp, and what it does is different from what the AVR and SAM code now does.

i.e the SAM code for wire::endtransmission looks like this

Code: [Select]
uint8_t TwoWire::endTransmission(uint8_t sendStop) {
uint8_t error = 0;
// transmit buffer (blocking)
TWI_StartWrite(twi, txAddress, 0, 0, txBuffer[0]);
if (!TWI_WaitByteSent(twi, XMIT_TIMEOUT))
error = 2; // error, got NACK on address transmit

if (error == 0) {
uint16_t sent = 1;
while (sent < txBufferLength) {
TWI_WriteByte(twi, txBuffer[sent++]);
if (!TWI_WaitByteSent(twi, XMIT_TIMEOUT))
error = 3; // error, got NACK during data transmmit
}
}

if (error == 0) {
TWI_Stop(twi);
if (!TWI_WaitTransferComplete(twi, XMIT_TIMEOUT))
error = 4; // error, finishing up
}

txBufferLength = 0; // empty buffer
status = MASTER_IDLE;
return error;
}


But the Maple Wire implementation is actually in a function called process() which is called from ::endtransmission

which looks like this

Code: [Select]


uint8 WireBase::endTransmission(void) {
    if (tx_buf_overflow) {
        return EDATA;
    }
    process();
    tx_buf_idx = 0;
    tx_buf_overflow = false;
    return SUCCESS;
}



uint8_t TwoWire::endTransmission(uint8_t sendStop) {
uint8_t error = 0;
// transmit buffer (blocking)
TWI_StartWrite(twi, txAddress, 0, 0, txBuffer[0]);
if (!TWI_WaitByteSent(twi, XMIT_TIMEOUT))
error = 2; // error, got NACK on address transmit

if (error == 0) {
uint16_t sent = 1;
while (sent < txBufferLength) {
TWI_WriteByte(twi, txBuffer[sent++]);
if (!TWI_WaitByteSent(twi, XMIT_TIMEOUT))
error = 3; // error, got NACK during data transmmit
}
}

if (error == 0) {
TWI_Stop(twi);
if (!TWI_WaitTransferComplete(twi, XMIT_TIMEOUT))
error = 4; // error, finishing up
}

txBufferLength = 0; // empty buffer
status = MASTER_IDLE;
return error;
}



which seems to result in return SUCCESS;  occurring for all addresses

I'd need to do a side by side of the code to see what the differences are, they look similar...
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 06, 2014, 12:26 am
Unfortunately my coding isn't up to much... That said I have cludged a repair on one library that went out of date.

I hope to get your github on a machine for the weekend so that I can at least contribute with some testing.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 06, 2014, 12:43 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
Wow, another one.  The more we look the more maple IDE derivatives we find.
I went through the various links listed... The last for armstrap requires esclipse for development.  The earlier one for arttools was only partially compatible with arduino.
Quote
Basic Arduino/Wiring functions supported are: 
 delay, millis, micros, delayMicroseconds
 pinMode, digitalWrite, digitalRead
 Hardware serial with 3 serial ports Serial1==Serial, Serial2 and Serial3
 analogRead
These "older" Arduino efforts suffer because they are pre- Arduino 1.0 efforts.  As bobCousins has prove, integration is just an un-ZIP with no changes to the base-Arduino environment with GUI 1.5.7.  And as rogerClark is showing, working with the STM32 core is straightforward, but slow.

As for I2C, I have not even attempted to test yet, but I see no reason that bit-bang will not be effective... It is essentially where the Maple folks were a few years back.  I have worked with I2C on PSoC ARM using hardware "cells" and that was straightforward since Cypress did that whole '100 Projects in 100 Days' series'.  I cannot comment on the STM32 implementation of hardware I2C yet.  Too few play cycles.

Quote
Whilst the bit banging approach works and is portable, doesn't it also consume more RAM and CPU cycles than the dedicated hardware?
At the 400KPBS rate, bit-bang is entirely adequate and puts only light strain on CPU bandwidth.  But at 3.4MBPS, hardware I2C has significant advantages.  The higher speed would be desired for external memory and such and if a lightweight wrapper for hardware I2C can be created, that would be advantageous. 


Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 06, 2014, 01:37 am
@mrbrunette


Bitbanging the I2C works OK up to around 250khz, but won't go beyond that without modifying the code that Maple wrote,

They use some inline'ed delay code, but with the call overheads, even if I set the delay to zero (0), I only get around 266khz

If I hack the code a bit and remove the calls to the inlined'ed delay function (which is actually a #define in the header), it goes a little faster but not much.

The reason its not much faster is that Maple have used individual functions to do things like Set the Clock to High, and set it to low again, and as you can imagine the call'ing overhead kills the performance if you're using it to generate clocks.

It may be possible to mark the clock pin functions as inline and get the compiler to increase the speed, but I'm not even sure why they went to such convoluted lengths e.g. they do this

Code: [Select]
void TwoWire::i2c_send_ack() {
    set_sda(LOW);
    set_scl(HIGH);
    set_scl(LOW);
}

void TwoWire::set_scl(bool state) {
    I2C_DELAY(this->i2c_delay);
    digitalWrite(this->scl_pin,state);
    //Allow for clock stretching - dangerous currently
    if (state == HIGH) {
        while(digitalRead(this->scl_pin) == 0);
    }
}



Edit. just tried making the set_scl as inline and the code size didnt change, so thats not the solution.

Anyway. I'm sure initially the default speed of 100khz or a best case speed of around 250khz would be adequate.

Actually I'd like more speed, so I have an incentive at least to push bitbanging to a bit faster, perhaps bypass digital write etc, as this code is specific to the STM32 platform, so its not really going to change in terms of what digitalwrite does at the low level
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 06, 2014, 02:04 am
maybe maple and arduino but i disagree that soft i2c is limited to 250khz in general. twice that is easy and 1mhz or more doable with a few tricks.

Whilst the bit banging approach works and is portable, doesn't it also consume more RAM and CPU cycles than the dedicated hardware?
not generally. ram usage is exactly the same (0) and for example my banged i2c routines actually occupy slightly less flash (ie wr 17 vs 22). its the initialization that causes hardware to take a bit more. of course 5 bytes difference is fairly insignificant even in a 1k chip like t13 and ludicrous for one that has 128k.

similar situation for spi, soft serial, etc. the real benefit of hardware peripherals is they are more integrated into the interrupt structure so can be a lifesaver in super busy applications. fortunately for me this accounts for only a couple percent of my projects. also sometimes a speed benefit but again almost as often just the opposite.

in any case for me thats usually outweighed big time by real advantages of soft io including more versatile pin usage and portability in situations just like this (avr to arm).

i think the biggest cause of soft-whatever prejudice is mindset. spec sheets rarely mention this approach and gurus like to show off so newcomers are pretty much brainwashed from the start. once on a track its hard to break free. i specially get a kick out of the guys who say timer and ints is best way to blink an led. lol.

then theres romantic attachment to out one and only favorite chip. we do like to show off our girlfriends "special features".
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 06, 2014, 02:16 am
@mrbrunette

Quote
As bobCousins has prove, integration is just an un-ZIP with no changes to the base-Arduino environment with GUI 1.5.7.
This is only partially true.

I guess the really really core stuff works, but things that I take for granted like memcpy don't get #included when just taking a 0022 hardware core from somewhere else
And String class was missing, as was sprintf and probably a whole bunch or other stuff.
And progmem stuff wouldn't initially compile either, and I had t copy the SAM stuff over to the STM hardware folder.

etc

The API on Wire had changed, so I did a really quick search and replace and fortunately that kinda' worked, it actually looks, that perhaps I should really have tried to copy the SAM wire.cpp across and work out what I'd need underneath to support what the SAM version does

However it all takes time, which i'm poor on at the moment.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 06, 2014, 02:19 am
Quote
Bitbanging the I2C works OK up to around 250khz, but won't go beyond that without modifying the code that Maple wrote,

They use some inline'ed delay code, but with the call overheads, even if I set the delay to zero (0), I only get around 266khz

If I hack the code a bit and remove the calls to the inlined'ed delay function (which is actually a #define in the header), it goes a little faster but not much.
I stand corrected for the STM32 but I was basing my experience on Cypress PSoC running at 48MHz.  Thee PSoC 4100 $4 board does not have configurable hardware SPI, but the 4200 version also $4 has 4 separate configurable hardware modules.  I need to go back and profile the bit-bang on the 4100.

Ray
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 06, 2014, 02:32 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
And String class was missing, as was sprintf and probably a whole bunch or other stuff.
And progmem stuff wouldn't initially compile either, and I had t copy the SAM stuff over to the STM hardware folder.
I just kind of expected this... Cypress PSoC M0+ was a similar issue because they used newlib, too. But, mostly all fixable with includes... After researching stdlib.

Arduino AVR implementation has spoiled us... It certainly is not this easy when outside ArduinoGUI.  I see it as a two-edged sword: one side easy for newbies and one side dulling the memories of trench fighters because it is easy!

But, with more SRAM, dedicated peripheral modules, higher clocks, and huge flash storage (sounds like the old mainframe programmers' arguments about hand-optimized code) easy is probably OK. 

HOWEVER:
Your unselfish effort is sincerely appreciated as you have added significant value to the point where the mini-Maple @under $5 is very usable (and becoming more so...). Sincere thank-you, Roger, +1.


Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 06, 2014, 05:10 am
Hi Ray,

No worries

I think I was generally approaching this expecting only minor differences, but because the Maple wrote their code prior to Arduino 1.0, the API they adhered to is now out of date.

So in a lot of respects, I should have probably just tried modifying the SAM versions of files e.g. Print.cpp rather than trying to bug fix and modify the Maple files.

With Wire, I'm tempted to just copy the SAM wire.cpp an wire.h into the STM tree and see just how many errors I get.

But as ever with software development there is a big trade off between getting something to work quickly so a project can proceed versus building something stable and supportable for the long term

And currently with the STM32 stuff I'm just going for short term fixes to get people on board, as the more people who are interested, (if they are programmers by trade or knowledgeable amateurs), the lager the pool of people who are available to find and fix bugs and push the platform forward.


Actually, if I can get Wire to work, and we can write a wrapper for Hardware SPI, I think the best way forward is to start doing things like posting videos to YouTube, or posting to the Showcase on the Arduino forum, because this section of the forum is really a quiet backwater only frequented by diehards !
And I suspect a lot of other people would be interested in a $5 72 mhz Arduino if they only knew it existed. ;-)

PS.

I also find that debugging with the Arduino platform is quite difficult, and slow.
For my day job I use loads of different IDEs including MS Visual Studio, and Eclipse (for Android) and also something called FlashDevelop (for Adobe Flash Actionscript 3), and all of these make the developer's life a lot easier than the Arduino IDE.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 06, 2014, 09:18 am
HOWEVER:
Your unselfish effort is sincerely appreciated as you have added significant value to the point where the mini-Maple @under $5 is very usable (and becoming more so...). Sincere thank-you, Roger, +1.
Ray
I totally agree, I have a full time day job and busy family life, but all I want to do is join in the fun here. I have been looking into VGA drivers for the 'ARMduino' (ha ha - couldnt resist) and I would like to adapt/write a 256 colour 400x300 version for the platform, I already have a Gameduino (which is awesome) but I am thinking this could be a very cheap simple version that leaves loads of processor time left for the main app. TVout for the 328 is very memory & time hungry
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 06, 2014, 02:26 pm
this section of the forum is really a quiet backwater only frequented by diehards !
And I suspect a lot of other people would be interested in a $5 72 mhz Arduino if they only knew it existed.
more descriptive thread title might help it to blossom too. not before some of the more useful functions are polished off though because you dont want to be flooded with beginner problems. nobbys armdunio sounds catchy and along with being the best innovation since original mega8duino should be quite a hit. the sam board wasnt quite the rage with that $45 price tag. consider you can buy 10 of these for that.

ps i would love to see vga code but probably involves assembler which from a quick browse of instruction set and tools dont look like too much of an option. at least not for me. :eek:

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 06, 2014, 03:51 pm
more descriptive thread title might help it to blossom too. not before some of the more useful functions are polished off though because you dont want to be flooded with beginner problems. nobbys armdunio sounds catchy and along with being the best innovation since original mega8duino should be quite a hit. the sam board wasnt quite the rage with that $45 price tag. consider you can buy 10 of these for that.

ps i would love to see vga code but probably involves assembler which from a quick browse of instruction set and tools dont look like too much of an option. at least not for me. :eek:


@John, I think once the dust has settled and Roger has crafted and nurtured this little beast into a tame lovable creature that everyone will want.. only then will a NEW topic arrive with all the instructions to install and program the ARMduino (sorry couldn't help myself again !) - Once the JTagging has also been tested on a variety of cheap-ish programmers that also can be added. Dilution of information will always happen on forums. Roger has a good little blog running which 'could' be used but that would be up to him as it is extra traffic on his site (not sure if that's wanted or not)

The VGA code is a work in progress, I have adapted the normal TVout library so that it works more efficiently and have added a method of creating 24bit colour (albeit only one colour at a time), also I have knife and forked in a 250kbps RXonly interface etc etc.. I think I could run something similar on the ARMduino but in 256 colours and would be pretty efficient, although MY application would NOT suit 99.9% of other peoples need, so a library would probably not be useful to anyone else :)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 06, 2014, 03:58 pm
ROGERS BLOG ABOUT THE STM32 BOARDS (http://www.rogerclark.net/stm32-boards-on-ebay-with-arduino-in-their-description/).. an interesting read, and perhaps he may add more in time ;)
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 06, 2014, 04:48 pm
wow. was that mentioned before? i guess a lot going on behind the scenes. if this works out im thinking of proposing as an addition to next years curriculum. maybe not replacement for the current avr base but in addition for those who might be curious. arm does appear to be the wave of the future.

btw without a 32khz xtl his first board there does not have the rtc function he commented on. the second does. the more i read up on these devices the more impressive the look.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 06, 2014, 06:25 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


wow. was that mentioned before? i guess a lot going on behind the scenes. if this works out im thinking of proposing as an addition to next years curriculum. maybe not replacement for the current avr base but in addition for those who might be curious. arm does appear to be the wave of the future.
The STM discovery board has been used previously in CS classes for labs, so you may be able to get some good material for a Maple'lized version.  PErsonally, I found this to be an easy read with good foundational materials taken from the RFM0008 ... but explained like a text book instead of a manufacturers' reference.  Highly recommended by me.
Caveat: PDF target (http://www.cs.indiana.edu/~geobrown/book.pdf)

Ray

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 06, 2014, 09:16 pm
@mcnobby

Armdrino is a catchy name. Its a bit cheeky really, because the Due is Arm as well at its core.
But that's the way marketing is...

I've been swamped with work this week, so have not made much progress with the STM32.

I did download Arduino 0023 last night to compare the Wire lib from Maple with that version, as its a contemporary.
I was hoping that perhaps Maple based their Wire code on the 0023 code (0023 is the last pre 1.0 arduino build, so is the old API and is very much like 0022 and 0021 etc).
But Maples code is quite different.

So there we no clues in there that would help when looking at why Wire doesn't function quite the same as for AVR and SAM.

I also downloaded STMs CPAL (Communications Peripheral Application Library), which has API functions for all the built in hardware. E.g SPI I2C CAN DMA ADC etc etc.

And I found a simple example on the web of how to use the hardware I2C API in CPAL to read and write to an I2C EEPROM..

But as I've indicated before I can't include this code in GitHub because of the source license :-(
frankly I think stm are shooting themselves in the foot with license conditions like this.
Its really specific to their hardware so I can't see how its in their interest to not release it under gnu

But with monoliths like this, is doubt things will change.


There isn't a lot of point in me writing a hardware i2c class that uses CPAL if anyone who wants to use it has to separately download CPAL

well... It is do able, I have used other software that you have to run an installer, and the installer gets the external libs and installs them in the correct location, but of course this relies on stm not moving the file location or removing it completely.


Actually.
Ummm perhaps this is more do able than I envisaged.

I can write an installer using the Nullsoft Installer System, NSIS, than downloads the GitHub zip and installs it into the hardware folder and then downloads  CPAL and installs that as well.

But I know this doesn't help Linux users etc

Anyway, worth thinking about.
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 06, 2014, 09:34 pm
But I know this doesn't help Linux users etc

Anyway, worth thinking about.

Or indeed Mac users. Frankly I think they are being a tad daft but you said that also...
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 06, 2014, 10:01 pm
@ChilliTronix

Quote
Or indeed Mac users.
Yes.. 

Sorry to leave out Mac users.

To be honest, Linux users tend to be able to download and install files, but Mac users are more akin to PC users and expect a more seamless experience.


I've not had time to look at either the Linux or Mac builds as yet.
(As should come as no surprise I have several macs, partially as I need them for work)


I have updated and tested the Python STM32 loader script, and it works on the PC, so I can't see any reason it won't work on the Mac, and linux, except possibly getting the path to the script correctly and also passing the comm port.

On the PC these arrive as arguements passed to the batch file that is called by the IDE, but I don't know how the Linux or Mac version does this.

I did download the Linux version a few days ago, and had a brief look at the files to see if it was obvious how the upload process was called e.g possibly a sh file instead of a bat, but I couldn't easily figure out how it worked without installing and running it on a Linux machine, and I don't have one up and running at the moment (that I can remember, but I do have a lot of machines, so perhaps I have a linux installation kicking around on one of my old laptops)



Re: Name

Armdrino


I did a quick search and surprisingly it didnt turn up any prior uses !

I wonder if this is because it includes trademarked names ?  (mainly ARM), but I can't see this stopping most people calling something by that name, or even registering a domain name etc
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 06, 2014, 10:34 pm
Roger, I think that if its a arduino thingy, it should end in 'DUINO

So that would be ARMduino, not ARMdrino

I found this --> ARMDUINO (https://groups.google.com/forum/#!topic/hackerdojo/NJstHEUD9I0)

Darn it, Ill have to think of an even cheekier name ! ha
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 06, 2014, 11:21 pm
(LOL)

Ah

http://www.thingiverse.com/thing:267683


Its a robotic arm   (ROFL)

Or

https://github.com/Railstars/ARMduino

(Out of date partial port to  NXP LPC17xx family of processors)


etc etc
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 06, 2014, 11:40 pm
Roger, at the weekend I will see what I can make of the Linux side of things, as I do have boards to hand it would seem rude not to....
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 07, 2014, 12:07 am
Quote
The STM discovery board has been used previously in CS classes for labs
And the TI Tiva Launchpad was used for the the UTX "embedded systems" MOOC.  (Which is being offered again, and is recommended: https://www.edx.org/course/utaustinx/utaustinx-ut-6-02x-embedded-systems-4806 )

Quote
Sorry to leave out Mac users.
FWIW, I downloaded your stuff and installed it on top of my Mac 1.5.8, and it compiles Blink just fine.
I haven't gotten further than that, nor tried to upload, yet.  I've been using https://code.google.com/p/stm32flash/ for uploading my assembly experiments to my "minimal development board."
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 07, 2014, 12:20 am
@westfw


OK.
STM32Flash is what I'm using on the PC it works well

I even have it running at 203400 baud, however it seems a bit intermittent about whether it makes the initial connection at that speed.  So I may go back to 115200

PS. Check the default speed in the code, I thought it was 115200 but I noticed it seemed to sometimes be 57600. So you'd be better off specifying the baud rate in the arguments list


Can you tell me how you are running it, e.g, off the command line or is there an equivalent to serial_upload.bat for OSX??

@chilltronixs

I guess you could compile stm32flash like @westfw has done, or alternatively it may be easier for you to use the python upload that I modified https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/tools/win/stm32loader.py

See the serial_upload.bat and also https://github.com/jsnyder/stm32loader  for arguements
(I've added -g for "GO"  which you should use as it saves having to reset the board after the upload is finished)

Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 07, 2014, 12:34 am
I suspect I will go with the python script and I will let you know.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 07, 2014, 12:51 am
Quote
I suspect I will go with the python script and I will let you know.
Thanks
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 07, 2014, 04:32 pm
Going to run up my Mapelduino tonight, soldered the pins on last night but ran out of time to mount the whole thing on a Vero sub-board with a USB/serial attached etc...

Wish me luck !
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 07, 2014, 08:24 pm
No worries

Let me know how you get on.

I currently have my generic stm32 board pluged into one of those no soldering required breadboards, with the USB to serial also plugged in, and 4 wires from the serial to the stm I.e 5v GND Rx and Tx

The important thing is to put the maple into the stm flash loader mode
If the maple led still flashes it will not upload via serial.

I don't have my maple boards yet, but looking ath the circuit diagram, the button is connected to boot0, so if you hold it down and then dab th reset button, the maple led should stop flashing.

Btw there is no indication on the board during upload, but if you set the arduino preferences to verbose the uploader exe reports percentage etc



I may have time to look at Wire I2CDev not working, some time over the weekend, but work pressure has effectively stopped me doing much during the week.
Title: I2CDev based Wire was working!
Post by: rogerClark on Nov 08, 2014, 11:42 am
Guys,

I thought I2CDev for Wire was not working, however I've found it was working, and that I have other hardware and software issues.

i.e I had tested Wire using a BMP085 barometer with The Adafruit library which I uses Wire directly worked OK.


But when I tried a different I2C device , an Intellisense MPU9150 motion sensor / magnetometer,   using a library called RTIMULib that uses the I2CDev and MPU6050 libraries, it would not work.

I thought this was a problem with I2CDev with Maple's Wire library implementation, however as I was also using different hardware it wasnt possible to know precisely where the problem lay.

So I found that I2CDev   https://github.com/jrowberg/i2cdevlib , has a library for the BMP085 barometer, so I tried this, to verify whether the problem was I2CDev for an electronics problem, and the BMP085 works fine using I2CDev.

I also noticed that I2CDev has a library for the MPU6050 which is from the same family as the MPU9150, except doesnt include the magnetometer, so I tried this lib to read the MPU9150 and it can read all data except the compass.

So my issue was something to do with the code for RTIMULib and its copy of the I2CDev library and its copy of MPU6050 library (or possibly some change I made)


I'm not too sure why the RTIMULib package is not working on the STM32, but does work on the UNO etc, but I think this is more likely to be either a problem in the RTIMULib or possibly a change I've accidentally made to its version of I2CDev or MPU6050 (libs)



But the good news is that I2CDev seems to work fine.

So I will dig out some other I2C peripherals and give them a go tomorrow (as its 9:30pm here)


I'd also like to test SPU, but I'll need to find a suitable test candidate, I have some Nokia 6110 displays that I could try as they are native 3.3V devices, so should be fairly easy to wire up, as they won't need any resistor dividers.

I would test a RFM24L01, but I find these devices intermittent at the best of times, as they seem very sensitive to supply interference. i.e so if they didnt work, it would be hard to prove if it was something in Wire or SDA / SCL, or if it was yet another supply noise issue.

But I guess in the long term I should test this

I also have some OneWire thermometers I bought for another project, so I could give that a try, however I'll need to determine what value of pullup resistor is needed for a 3.3V supply






Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 08, 2014, 02:21 pm
i have on hand all of the i2c and spi devices you mention and when my boards arrive will be in a good position to test. most people have no hint of the problems you mention with 24l01 and they are rock solid for me. even with the dirtiest dc supplies and wide range of batteries so i suspect there must be something else wrong on your end. the gyro/accel can be a little off with noise but only the data. im thinking virtually everybody has 24xx eeproms somewhere in the house so those are another good test case.

if serial, i2c, and spi are operational then probably 99% of the arduino code floating around out there will work or close to it. the arduino i2c scan demo might be a good acid test regardless of what device is actually hooked up.

im not sure what i2cdev means. is this part of the scan demo?

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 08, 2014, 08:37 pm
@john1993

I2CDev https://github.com/jrowberg/i2cdevlib. Is a core library plus a load of other device specific libraries for communication with i2C devices.

I've seen it used several times, and the lib for the IMu sensor uses it.


Re NRF24L01

Perhaps my issue was not supply noise, however even the basic ping pong demo was intermittent for me between a UNO and a mega2560 so either by modules are dodgy or its some electrical problem


Re i2cscanner

No. It doesn't work.

I will take a look at the problem today. Its because the Maple Wire class returns a different response to the latest Arduino Wire library, for the endTransmission function.

In that maple wire always returns SUCCESS where as the Arduino Wire returns various codes depending on what actually occurred.

I'm not sure how hard it will be to fix, as there aren't any comments in the arduino code to indicate under what circumstances it returns these different code numbers.

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 08, 2014, 08:57 pm
@westfw

I'm thinking of getting one of those Stm Nucleo or Discovery boards to test with the Arduino IDE.

However I'm a bit torn about whether to get a F4 variant. I.e  I'm fairly certain that the F1 serial boards would work with the Arduino IDE, as they have pretty much the same chip as in the maple.

So I'm inclined to look at a board with a more powerful processor hence something featuring the F4, even though it may initially not be compatible with the Arduino IDE.

But one thing I can't quite see is the clock rate on these F4 boards run at. According to the specs the F4 has variants up to 180mhz, but it looks like the Nucleo boards are all the same sort of clock rates as the maple.

Edit. Looks like the 429 can run at 180mhz, but I better do some more research before I buy anything ;-)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 08, 2014, 09:21 pm
Guys.

Just to flag another possible source of information etc

I noticed references to Olimex in relation to Maple etc, and finally got around to finding out what is was

See https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/

Basically its a Maple clone

The interesting thing is probably any libs that have been written for it, as they could be useful.


EDIT.

lol..

Just looked at Olimex CAN Demo and it includes the sources from STMs CPAL lib, which legally I'm not sure they are allowed to distribute.

Also, strangely they include a load of .o files, I.e pre compiled cpp or assembler files.

I could see why they'd do this to possibly get adhere to STMs license, but they still include at last one cpp file, and I'd have expected only header files, if this was a method to use these within the license.


Still. If CPAL could be used by just distributing .o files and headers, it would still may all the necessary code for hardware libs to be distributed legally.

However I'd have to re read the CPAL license legal gibberish to see if I could understand quite what ST envisaged
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 08, 2014, 09:23 pm
But one thing I can't quite see is the clock rate on these F4 boards run at.
Funny, I did exactly the same thing last night.. I looked everywhere and not a single advert would give the on board clock speed of the Dev board, some of the F4 variants are pretty awesome though, they have some extra chips or perifs on there, im sure I saw gyro and acceleration

Although I love the look of the Nuclii (ha) I felt a bit short changed on information and specs of the boards, each advert seem to have copied the (lack of) info from the ST page :(
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 08, 2014, 09:26 pm
I noticed references to Olimex in relation to Maple etc, and finally got around to finding out what is was

See https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/

Basically its a Maple clone

The interesting thing is probably any libs that have been written for it, as they could be useful.
I was looking at this board a couple of weeks ago, I finally got round to buying the Olimex MOD-VGA board (similar to the Gameduino board) - looked a pretty good board so I got it, far cheaper than the original, very good quality. I have bought several things from Olimex :)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 08, 2014, 10:33 pm
@mcnobby

There is a company in Germany selling the Discovery and Nucleo boards on eBay, so I'm going to send them a message (on ebay) to see if they can tell me what the clock rates are

As far as I can tell the Nucleo boards are not using the newer STM32F4 devices  and are equivalent to the Maple, but perhaps have some peripherals. They do have however Arduino style headers, which I presume they connect power and GND etc to the correct pins, so that some Arduino Shields may work, assuming software compatibility.

It looks like the Discovery line of ST boards, are the ones with the high clock rates, but possibly only the one with the LCD display on it, is capable of 180Mhz, but it costs more because of the display.
There appears to be another Discovery board running at something like 162Mhz that doesnt have the LCD display and is a few pounds (or dollars or euro's etc) cheaper...



BTW.

Have you managed to attach your USB To Serial to your Maple mini yet? (or did I miss a posting ;-)


I made some progress with I2CDev last night (it was basically working all the time, after I'd modified Wire.h to include a define for BUFFER_SIZE  (umm I better check I pushed that version to GitHub, but made the change a week ago, so I think I should have pushed it)


As John1993 mentioned I2CScanner, I'm just going to see if I can get it working, as I think its currently  not working, because of differences in Wire.endTransmission

Title: Re: I2CScanner
Post by: rogerClark on Nov 08, 2014, 11:16 pm
It looks like I'll need to read and understand the I2C protocol specification, because what Maple did, doesn't seem to work at all for scanning the I2CBus


Basically their for Wire:endTransmission does this (I've manually inlined what the function calls are doing



Code: [Select]
// set SDA and SCL to low
    set_sda(LOW);
    set_scl(LOW);

// Clock out the target address (I think )

    for (i = 0; i < 8; i++) {
        set_sda(!!(val & (1 << (7 - i)) ) );
        set_scl(HIGH);
        set_scl(LOW);
    }



// Check for ACK

    set_scl(LOW);
    set_sda(HIGH);
    set_scl(HIGH);

    bool ret = !digitalRead(this->sda_pin);
    set_scl(LOW);


    if ( !ret)
   {
        return ENACKADDR;
    }



Actually the code is this


Code: [Select]


bool TwoWire::i2c_get_ack() {
    set_scl(LOW);
    set_sda(HIGH);
    set_scl(HIGH);

    bool ret = !digitalRead(this->sda_pin);
    set_scl(LOW);
    return ret;
}



// called here

if (!i2c_get_ack()) {
        return ENACKADDR;
    }




I suspect that i2c_get_ack isn't really working

I guess I better post to a different thread, so that someone who knows about I2C can point me in the right direction


Edit.

I've found the problem is something to do with this code but its the opposite of what I thought.

There is a bug in endTransmission because it always returns SUCCESS because it doesn't pass back the return value from process()

But it looks like process() has a bug as its returning that all addresses are giving NACK responses, which can't be true as I have a device attached which I've just double checked and is working

This code in process() always fails

Code: [Select]
    if (!i2c_get_ack()) {
        return ENACKADDR;
    }


So I suspect there is a problem in
Code: [Select]

bool TwoWire::i2c_get_ack() {
    set_scl(LOW);
    set_sda(HIGH);
    set_scl(HIGH);

    bool ret = !digitalRead(this->sda_pin);
    set_scl(LOW);
    return ret;
}


Time to post to the protocols forum
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 08, 2014, 11:41 pm
Odd question but have you thought of just throwing the Arduino I2C library at it and seeing what falls over?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 08, 2014, 11:56 pm
@ChilliTronix

I looked at both the AVR and SAM wire libs and neither of them would have worked at all, as they are written totally differently

Maple seem to have totally gone their own way when writing Wire and didn't follow even the general structure of what the Arduino IDE even on Arduino 0022 was doing

Wire on AVR and SAM now look quite different to each other as well.

I think its easiest just to try to fix this one minor isue with incorrect determination of the ACK / NACK responses.


Edit. BTW. Did you get around to testing using the Python uploader?

Recently I've been finding the PC exe uploaded a bit flakey and I need to reset and try again.
I'm not sure why its started doing this. Possibly loose connections on my breadboard , either way its a pain.
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 09, 2014, 09:10 am
Quote
But one thing I can't quite see is the clock rate on these F4 boards run at. According to the specs the F4 has variants up to 180mhz, but it looks like the Nucleo boards are all the same sort of clock rates as the maple.
It looks to me like the F401 board is 84MHz, and the F411 board is 100MHz.
For all of these, you have to look up the chip used for the max clock speed.  All of them have fancy PLL-based clock circuits that will multiply the frequency from an external crystal by some integer value.   There may be details that prevent reaching the exact "max" speed (say, the 100MHz chip only supports clock multiplication for 12x the 8MHz crystal for 96MHz), but the chip limits are going to be approximately as per the chip specs.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 09, 2014, 10:21 am
@westfw

Thanks
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 09, 2014, 10:41 am
@mcnobby
As far as I can tell the Nucleo boards are not using the newer STM32F4 devices 
http://www.ebay.co.uk/itm/Nucleo-STM32F4-Discovery-STM32F401-Development-Board-Arduino-/161356505064 (http://www.ebay.co.uk/itm/Nucleo-STM32F4-Discovery-STM32F401-Development-Board-Arduino-/161356505064)

BTW. Have you managed to attach your USB To Serial to your Maple mini yet? (or did I miss a posting ;-)
ha ha, I was all set to yesterday, but just decided to upload code my a new 328 pcb, ended up struggling for hours thinking I had a hardware issue, in the end it was defualt_bitrate in avrdude, doood !!!
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 09, 2014, 11:10 am
Quote
ha ha, I was all set to yesterday, but just decided to upload code my a new 328 pcb, ended up struggling for hours thinking I had a hardware issue, in the end it was defualt_bitrate in avrdude, doood !!!
(lol)

I know the feeling.. That sort of thing happens to be all the time ;-)

Edit.

OK about there being an F4 Nicleo. however according to Wikipedia its only 84Mhz, so there doesnt seem to be much point in me getting another board with similar performance, albeit the M4 Arm processor if faster per clock cycle than the F1

From http://en.wikipedia.org/wiki/STM32#Discovery_boards
Quote
NUCLEO-F401RE board for STM32F401RET6 microcontroller with 84 MHz Cortex-M4F core, 512 KB Flash, 96 KB RAM in LQFP64 package.
And  bit further down

Quote
STM32F429IDISCOVERY

    A discovery board for STM32F429ZIT6 microcontroller with 180 MHz ARM Cortex-M4F core, 2048 KB Flash, 256 KB RAM, 4 KB battery-backed RAM in LQFP144 package.[27]
    This board includes an integrated ST-LINK/V2 debugger via Mini-B USB connector, 8 MB SDRAM (IS42S16400J), 2.4-inch 320x200 TFT LCD color display (SF-TC240T), touchscreen controller (STMPE811), gyroscope (L3GD20), 2 user LEDs, user button, reset button, Full-Speed USB OTG to second Micro-AB USB connector, and two 32x2 male pin headers
i.e the Discovery board

http://www.ebay.co.uk/itm/Development-Board-STM32F4-Discovery-STM32F429-TFT-LCD-STM32-ARM-Cortex-M4-/151351467028?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item233d401c14 (http://www.ebay.co.uk/itm/Development-Board-STM32F4-Discovery-STM32F429-TFT-LCD-STM32-ARM-Cortex-M4-/151351467028?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item233d401c14)


Looks like its the fastest one, but it does cost considerably more than the Nucleo with F4.
i.e £22 + P&P instead of  £10.73 + P&P


The next fastest by around 20Mhz is better value
http://www.ebay.co.uk/itm/STM32F4-DISCOVERY-USB-STM32F407VGT6-STM32-ARM-Cortex-M4-Development-Board-/151289777040?pt=Mess_Pr%C3%BCftechnik&hash=item233992cb90 (http://www.ebay.co.uk/itm/STM32F4-DISCOVERY-USB-STM32F407VGT6-STM32-ARM-Cortex-M4-Development-Board-/151289777040?pt=Mess_Pr%C3%BCftechnik&hash=item233992cb90)


at "Approximately £11.32" (original price listed in euros) is probably the best bang for buck ratio,

But the Maple mini's are still overall probably the best value.

But if you had the STM32F429 running at 180Mhz with the M4 core, I think you'd probably own the fastest Arduino I've heard of (though I'm sure someone will tell me there is something faster ;0)

i.e its twice the clock speed of the Teensy ;-) and on the same ARM core, so should be approximately twice as fast, albeit the Tweensy probably doesn't use bitbanging for I2C and SPI....



Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 09, 2014, 11:12 am
@Roger

Opened IDE 1.5.8 with STM32 libraries
Opened blink sketch, set board to STM32 to flash - No Bootloader

Complied, and got this result (not sure what it all means though...)

Code: [Select]
In file included from C:\Arduino 1.5.5\hardware\Arduino_STM32-master\STM32F1XX\system/libmaple/include/libmaple/stm32.h:70:0,
                 from C:\Arduino 1.5.5\hardware\Arduino_STM32-master\STM32F1XX\variants\maple_mini\libmaple\stm32f1\performance\isrs.S:29:
C:\Arduino 1.5.5\hardware\Arduino_STM32-master\STM32F1XX\system/libmaple/stm32f1/include/series/stm32.h:86:0: warning: "STM32_MEDIUM_DENSITY" redefined [enabled by default]
 #   define STM32_MEDIUM_DENSITY
 ^
<command-line>:0:0: note: this is the location of the previous definition
In file included from C:\Arduino 1.5.5\hardware\Arduino_STM32-master\STM32F1XX\system/libmaple/include/libmaple/stm32.h:70:0,
                 from C:\Arduino 1.5.5\hardware\Arduino_STM32-master\STM32F1XX\variants\maple_mini\libmaple\stm32f1\performance\vector_table.S:29:
C:\Arduino 1.5.5\hardware\Arduino_STM32-master\STM32F1XX\system/libmaple/stm32f1/include/series/stm32.h:86:0: warning: "STM32_MEDIUM_DENSITY" redefined [enabled by default]
 #   define STM32_MEDIUM_DENSITY
 ^
<command-line>:0:0: note: this is the location of the previous definition

[b]Sketch uses 10,428 bytes (9%) of program storage space. Maximum is 108,000 bytes.[/b]
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 09, 2014, 11:26 am
I get those warnings as well.

It doesn't seem to matter.

I recall Bobc, who originally copied and modified the LeafLabs code into Arduino mentioning some warnings, but I don't know if it was that specific warning.

Its just a redefinition of something.

If I get chance I'll just run the preprocessor and see if I can figure out what it is and any its occurring, I presume that one of the headers doesn't check for re-inclusion.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 09, 2014, 11:32 am
Cheers Roger, gonna be linking up next :)

Thanks for the infor regarding the F4's... I thought I had seen a gyro in there somewhere !! lol

Seem VERY good value for money, bang for buck

Now lets talk about the RaspberryPiDuino !! lol ;)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 09, 2014, 11:40 am
OK.

I can see why its giving this warning.

In boards.txt

STM32_MEDIUM_DENSITY is being defined in the compiler flags


Code: [Select]

maple.build.extra_flags=-DMCU_STM32F103RB -mthumb -DSTM32_MEDIUM_DENSITY -DBOOTLOADER_maple -march=armv7-m    


But its also being defined in

Arduino_STM32\STM32F1XX\system/libmaple/stm32f1/include/series/stm32.h

So it could probably be removed from stm32.h.


Looking at the original Maple copy of boards.txt the .extra_flags was not present, hence it looks like this was added by bobc.

As the extra_flags are added to all files when they are compiled (as far as I can tell), it would be best to remove the line from stm32.h, rather than the other way around, otherwise depending on when stm32.h was included during the build process, it may or may not have been defined when some files are compiled.

I don't have time to try removing it from stm32.h now, but I'll give it a go tomorrow (or you could give it a shot i.e comment it out in stm32.h)

Cheers

Roger

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 09, 2014, 11:42 am
Quote
Now lets talk about the RaspberryPiDuino !! lol ;)
True

PI as Anrduino would be faster again, but someone would have to write all the libs.

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 09, 2014, 08:02 pm
PI as Anrduino would be faster again, but someone would have to write all the libs.
It would have some cracking video capabilities though !!

I already have one running as a media server and internet video streamer.. for the money probably one of my best buys, but I really must get round to playing python or writing some scratch :)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 09, 2014, 11:26 pm
I have a RPI as well; one of the early'ish versions, not the fancy new ones ;-).

I thought perhaps it would be usable for high end things as a replacement for the Arduino, but I quickly learnt that they are entirely different beasts.

As you say, use as a media server etc, is better use for the RPI than controlling relays etc.
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 10, 2014, 01:05 am
The Pi is great where you want or need a small computer, it has after all got an ethernet shield and an MP3 shield as well as am SD card shield all built in, but is over kill when most jobs can be done with a Pro Mini.

Title: Re: What's this I found on eBay?
Post by: westfw on Nov 10, 2014, 03:42 am
Quote
PI as Arduino would be faster again,
You could do "PC as Arduino", which has interesting debugging possibilities.
And infinite numbers of "xxx.write" ports, each opening up a new text window.
You could use the sound card as a couple of analog inputs/outputs, but connecting "real" hardware would require additional hardware (something like an ATmega-based Arduino...  :-))
(for OLD PCs, you could use the actual parallel and serial ports.)

Title: I2CScanner fixed !!
Post by: rogerClark on Nov 10, 2014, 11:25 am
Hi Guys,

I've not pushed these changes to my GitHub repo yet, but I've fixed the issue(s) that caused the Arduino Playground "Scanner" not to work.


There were 2 problems in the Wire library.

1. Wire.endTransmission was always returning success rather than passing back an internal status from Wire.process() which actually indicated the result of ending the transmission

2. A bug in the process() function where if the code exited before the end (because it failed to get an ACK signal back from the target device), the SCL line was left at the wrong state. (low instead of high)

So I've changed the Wire library to fix both these issues and the I2CScanner now seems to be working fine.


It never ceases to amaze me that bugs like this in Maple's code were not picked up by anyone and fixes up into the code. But I guess you need a logic analyser or an oscilloscope to look at these things


So for anyone who is interested.

The first image, is the address of my MPU9150 module 0x68 being sent via I2C and the device responds by pulling SDA low, which Wire reads the state of, and returns SUCCESS

The second image, is when an invalid address is sent, in this case I sent 0x67, and the device doesn't respond, but note the SCL line is left in a low state.

The last image, is where following the attempt to address 0x67, the code now tries to address 0x68 again, but as SCL is low from the last transfer, the first BIT of data doesn't get clocked out, and hence the whole transfer is garbage, as the slave device only gets 7 clock pulses for the address instead of 8.


Anyway. Now I've solved that mystery, I can go back to going what I really intended to do which is actually to read data from the PU9150 (and currently its failing to read the compass data because the lib I'm using is for the MPU6050 which doesn't have a compass)
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 10, 2014, 01:01 pm
that is fantastic news. i cant wait any longer so have ordered one of the c8 boards like in your blog from a us seller. hopefully it will arrive in a couple days instead of waiting another month for the ones from china.

one question, are your i2c routines hardware or bitbang? what difference from the ones paulrb used last week?

I have an I2C sketch running on my Maple Mini clone. Hooked up a ds3231 rtc, with 4K7 pullups on sda/scl, although it seems to work ok without them (suspect my ds3231 module has them built-in).

Code: [Select]
#include <Wire.h>

//RTC Data
#define RTCadrs 0x68
#define RTCrequestTime 0x00
#define RTCrequestTemp 0x11
#define RTCsetControl 0x0E

void setup() {
  Wire.begin();
}

void loop() {
 
  char buff[80];
  byte RTCsecs,RTCmins,RTChours;

  //get current date & time from RTC
  Wire.beginTransmission(RTCadrs);
  Wire.send(byte(RTCrequestTime));
  Wire.endTransmission();
  Wire.requestFrom(RTCadrs, 3);
  RTCsecs = Wire.receive();
  RTCmins = Wire.receive();
  RTChours = Wire.receive();

  SerialUSB.print(RTChours, HEX);
  SerialUSB.print(":");
  SerialUSB.print(RTCmins, HEX);
  SerialUSB.print(":");
  SerialUSB.println(RTCsecs, HEX);
 
  delay(1000);
   
}



I did make a change to the file Wire.h:

Code: [Select]

#define SDA 15
#define SCL 16


So the suspicion is that this is a bit-bang software i2c?
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 10, 2014, 08:19 pm
I can see I am going to have to budget for a scope.... What frequency did you use Roger?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 10, 2014, 08:45 pm
@chillitronix

I have a 100mhz rigol, old model DS1102D which also has a 16 channel logic analyser.

I use it quite often. 100mhz has been ok for Arduino work so far, and would be ok even to look at clocks on the these STM boards.

I don't think its worth getting a faster scope as the prices start to get extreme beyond 100mhz.

Although I have the logic analyser model, which has a separate input socket for the logic probes module, I hardly ever use the logic analyser.

Most of the time the two analogue inputs are adequate, but if you are serious about doing digital work, I guess you should see if you can afford it, even if you hardly ever use it.


I looked at PC based scopes as well as dedicated units, and at the time was that PC scopes were not up to the job.

The Rigol I have does everything I need and more.

The new Rigols have bigger screens, which would be nice to have, but apart from that my ds1102D is fine for me.

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 10, 2014, 09:05 pm
I got one of THESE (http://www.ebay.co.uk/itm/Nano-Mini-DSO203-4-CH-Handheld-Storage-Digital-Oscilloscope-/171350304453) for christmas last year

not that great at high frequencies, but very usable for the money
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 10, 2014, 09:48 pm
Re: Scopes

Strangely they now seem more expensive than the price I paid 2 or 3 years ago

http://www.ebay.co.uk/itm/New-Rigol-Oscilloscope-100MHz-DS1102D-logic-analyzer-/300349473558?pt=UK_BOI_Electrical_Test_Measurement_Equipment_ET&hash=item45ee394316 (http://www.ebay.co.uk/itm/New-Rigol-Oscilloscope-100MHz-DS1102D-logic-analyzer-/300349473558?pt=UK_BOI_Electrical_Test_Measurement_Equipment_ET&hash=item45ee394316)


I'd need to double check, but from what I recall paid around £400 from an eBay shop in the USA who shipped direct from China (where they are made).

Perhaps there was some sort of special offer on at the time

Title: Re: What's this I found on eBay?
Post by: CrossRoads on Nov 10, 2014, 09:55 pm
I went big time myself - GW Instek, 4-channel, 200 MHz, made in Taiwan (vs China)
http://www.gwinstek.com/en/product/productmcategory.aspx?pid=3&&mid=7 (http://www.gwinstek.com/en/product/productmcategory.aspx?pid=3&&mid=7)
GDS-2204A, shipped from US supplier (in NY I think)
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 10, 2014, 11:08 pm
Crikey! Well I like the price of the DSO203, but it only does 8MHz, but can't afford the Rigol, which looks great!

I will have to ponder... And look up the prices of the GW Instek.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 10, 2014, 11:09 pm
wow

Nice scope

but $5000+ from element 14 is a bit beyond (well a lot beyond) by budget ;-)


http://au.element14.com/jsp/displayProduct.jsp?sku=1277407&CMP=KNC-GOO-PLA&gross_price=true&mckv=w9UmhkAz|pcrid|59148083448

Edit found it cheaper here

http://www.saelig.com/PSBE1004/PSBE1004005.htm

Still $2000 is probably a good price but too rich for me.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 10, 2014, 11:14 pm
@chilltronix

I guess it depends on what you need to do

I hardly every use the logic analyzer, and most problems are with preripherals at less than 50Mhz  so the DS1052E  would be good enough and is only £190

http://www.ebay.co.uk/itm/like/121183714991?limghlpsr=true&hlpv=2&ops=true&viphx=1&hlpht=true&lpid=107&chn=ps

(possibly cheaper elsewhere)

BTW there used to be a firmware hack to allow you to operate it the 50Mhz ones at 100Mhz i.e increase the timebase speed, as 99% of the electronics in the scope is the same as the 100mhz version.

However I decided not to risk a modded firmware update, and also I thought it would be better to buy on which was guaranteed to operate at 100Mhz
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 10, 2014, 11:28 pm
Guys,

FYI.

Back to the core subject ;-)

Re: @mcnobby's posting about warnings during compile

I think the safest thing I can do is just to wrap those #define in #ifndef 's   so that we don't get the message.

i.e The define is being passed as a compiler argument, rather than coming in from another header, and I think it would probably be safe just t comment out these duplicate definitions

But just in case someone later decides to change the compiler defines, the #ifndef solution is probably safer.

I'll take a look at doing that later and also uploading the fixes for Wire , so that I2C_Scanner works ok (and so that I2C in general doesn't pack up if there is a data error - missing ACK)

 
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 10, 2014, 11:41 pm
That Rigol is affordable! I will set aside a budget for something like that, many thanks!
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 10, 2014, 11:47 pm
Take a look at the eevblog vids

http://www.youtube.com/watch?v=sO5iGwHpmHc


There is one comparing it with the new model (which is twice the price) as well, but unless you want to pay $1000 ..... It will just be depressing about what you get for $1000
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 11, 2014, 01:41 am
roger, are the i2c routines you are working on hardware or bit-banged? are they the same ones used earlier in this thead that have been modified or different ones from another library?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 11, 2014, 04:18 am
@john1993

The ones I got from libmaple on github (which are theoretically the latest repository) are bit banged.

I'm not aware of a hardware implementation. The other version I found which is in the IDE installer zip, is also bit banged, but different from the bit banged version in libmaple on GitHub


The bit banged implementation seems to work, but isn't especially fast. The fastest I can get out of it (as stated earlier in this thread) is just over 250kHz which is a long way sort of ever fast I2C at 400kHz let alone the new even faster standard of over 3MHz.


I've not found any hardware implementations on the Maple forum either. e,g,
http://forums.leaflabs.com/topic.php?id=1195 lists some code that is no longer available

Someone referenced the ST CPAL lib's but they have license restrictions.

I'm not sure if anyone reads my ramblings about this, but I have found example code of using CPAL lib for I2C and I could write a Wire wrapper class, if I had a few hours to spare (which I don't at the moment due to pressure of work)

However, I'd probably need to compile CPAL to a library i.e like a .o file etc as the source for the library, although freely available is not transferable, so can't be included on GitHub.

I think until there is more interest in this board, everyone will have to live with bit banged I2C

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 11, 2014, 04:44 am
good news. actually at this time i prefer the bit bang method for reasons mentioned. theoretically we could use any of the mcu pins which i like. imo arduino's strong point is compatibility and portability not so much performance. we have direct gcc and other tools for that. when you are finished updating this i will download your package and follow the tutorial. thanks again for making this all possible.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 11, 2014, 05:30 am
@john1993

OK.

I have hard coded the Wire lib its self to use the pins for hardware I2C channel 1, I may need to change this back, as I'm not sure what pins these are mapped to on the Maple Mini, as I have a feeling that Maple may not have silk screened the normal I2C pins as the ones to use.

ie its using PB6 and PB7

If you want to use different pins you'd need to instantiate your own copy of TwoWire i.e like Wire.cpp does at the bottom

Code: [Select]

TwoWire Wire(PB7, PB6, SOFT_FAST);



If I remember I'll try to dig out what STM pin ID's Maple used for I2C and change it.

But as I'm not using a Maple at the moment it makes more sense for me to use the real names of the pins, not the Maple mapped names.
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 11, 2014, 06:03 am
i agree that using the hardware pins with bit banged i2c is best in case of future switchover to built-in. however it is nice to be able use other pins in case we need to free up those precious pwm outputs.

for avr i prefer using atmel signal names. that queer ardunio terminology always struck me as one of the drawbacks. specially with new chips like the m1284. that and the wacked header placement. creativity can be a good thing but not always.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 11, 2014, 10:17 am
Guys,

I've finally got around to pushing my latest fixes to my github repo.

Fixes are


1. Changed st32.h to prevent compile warnings about redefinition of STM32_MEDIUM_DENSITY
2. Changed Wire so that it was compatible with I2CDev by defining BUFFER_LENGTH
3. Fixed bugs in Wire, which prevented I2CScanner.ino from the Arduino Playground from working, This was quite a serious bug which had other implications, and would cause I2C to fail permanently if any transfers had problems, and an ACK was not received from the target address.
4. Fixed mistake I made when defining which pins to use for SCL and SDA (I had them reversed), they are now on pins PB6 and PB7, which are the pins used by the hardware I2C channel 1 - for future compatibility in case hardware I2C is every written.
See http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00161566.pdf  (page 32) for the pin assignments.

I've tested the I2CScanner and it now seems to work fine. I've tested it with 1 and 2 different devices attached.

I have tested it with a normal Wire based sketch communicating with a BMP180  and also via I2CDev (wrapper) to an MPU9150 motion sensor. Both of which worked fine.


Edit. In case anyone is coming into this thread now. The repo containing the STM32 stuff is
https://github.com/rogerclarkmelbourne/Arduino_STM32/archive/master.zip (https://github.com/rogerclarkmelbourne/Arduino_STM32/archive/master.zip)


Enjoy.


Roger
Title: Hardware SPI and SD Card
Post by: mrburnette on Nov 11, 2014, 02:18 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Reference Link (http://polplaiconesa.com/tutorials/SPI+DMA.html)
Quote
The ARM micro controller in the Maple has two built-in SPI ports. In the following table you can see what is the pin map for the different Maple boards:

Maple v5/ Maple RET6

Pin 10 - SPI1 Chip selector
Pin 11 - SPI1 MOSI
Pin 12 - SPI1 MISO
Pin 13 - SPI1 Clock

Pin 31 - SPI2 Chip selector
Pin 32 - SPI2 Clock
Pin 33 - SPI2 MISO
Pin 34 - SPI2 MOSI


Maple Mini


Pin 4 - SPI1 MOSI
Pin 5 - SPI1 MISO
Pin 6 - SPI1 Clock
Pin 7 - SPI1 Chip selector

Pin 28 - SPI2 MOSI
Pin 29 - SPI2 MISO
Pin 30 - SPI2 Clock
Pin 31 - SPI2 Chip selector
Quote
But as I'm not using a Maple at the moment it makes more sense for me to use the real names of the pins, not the Maple mapped names.
You're doing all the effort, which is appreciated, but is hard-coding really what you want to do?  Would not it be more desirable to have a new boards.txt entry for your STM32 and then sort out the Maple/Maple-mini pin issues after-the-fact?  The loopback that I did on hardware SPI worked as expected, however, I have not had the opportunity to extend this quick test to a TFT or other SPI device.

SPI and SD-Card

This article Idiot guide to using SD (http://forums.leaflabs.com/topic.php?id=2043) in the Maple forum suggests that SPI hardware works with a modified SD library.  I downloaded dinau's files, installed for the MapleIDE, and did a test compile on my Win8.1 64-bit.  The compile was successful and no errors:
Quote
C:\Users\Ray\AppData\Local\Temp\build7849661881275998487.tmp\FileSys.cpp.bin  :
section    size   addr
.data   21224      0
Total   21224
I need to sort through this and install into the 1.5.7 area for MapleMini and do a test compile from there, hopefully later today or soon.

Obviously, a successful compile is not an affirmation of working code, but it is encouraging.


Ray


Readme file:
Code: [Select]
This is SdFat library for Maple(STM32 micors) ported and derived from both
maple-sdfat ( http://code.google.com/p/maple-sdfat/downloads/list )
and Arduino1.0 SD class and File class.

You can use the primariy functions of SdFat and the wrapper functions as SD
class ported from Arduino1.0.

Prerequisite:
  You have to install the Ethernet library for Maple.
     https://bitbucket.org/dinau/ethernetmaple/downloads

Environment:
  MapleIDE v0.0.11, v0.0.12, libmaple-v0.0.12
 
Install:
  Unzip archives. Copy SdFat folder and Ethernet folder to "libraries" folder
  in MapleIDE installed, then restart MapleIDE.

Configuration:
  To decide SPI port and to change default settings, edit "libraies/SdFat/Sd2Card_config.h".
 
Usage:
   To open examples from menu,  File - Examples - SdFat,
   you can complie and execute almost examples.

Wiki:
   https://bitbucket.org/dinau/sdfatmaple-vld/wiki/Home

License:
  This library is under GPL3 same as maple-sdfat lib and Arduino1.0 SD Class and File class.
  Modified and porting, (C) Copyright 2012-2013 dinau.
  http://avr.paslog.jp/article/2408032.html


by dinau 2012/03.

v03: 2013/02
  Improved read/write speed,
    2G byte MicroSD card [Transcend], FAT16
    SPI clock       write       read
    4.5MHz        153kb/sec     289kb/sec
     9MHz         176kb/sec     396kb/sec
    18MHz         192kb/sec     485kb/sec
([kb/sec]=[kilo byte/sec])

References:
  Maple STM32
  http://leaflabs.com/
  Arduino1.0
  http://arduino.cc/en/Main/Software
  maple-sdfat
  http://code.google.com/p/maple-sdfat/downloads/list
  sdfatlib
  http://code.google.com/p/sdfatlib/




** SD - a slightly more friendly wrapper for sdfatlib **

This library aims to expose a subset of SD card functionality in the
form of a higher level "wrapper" object.

License: GNU General Public License V3
         (Because sdfatlib is licensed with this.)

(C) Copyright 2010 SparkFun Electronics

Now better than ever with optimization, multiple file support, directory handling, etc - ladyada!
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 11, 2014, 04:59 pm
ray, did you use the zip file that roger just posted?

probably easiest and most common spi device is an sd card. like 24xx for i2c its something everybody has and there are official arduino demos for both. mine are wired up and ready to go when my board shows up.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 11, 2014, 05:03 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


ray, did you use the zip file that roger just posted?

probably easiest and most common spi device is an sd card. like 24xx for i2c its something everybody has and there are official arduino demos for both. mine are wired up and ready to go when my board shows up.
No.  I have not used that ZIP, yet.  I was trolling looking for folks that had successfully implemented HardwareSPI on the Maple or "clones" using the MapleIDE.  I was looking for a port of the ILI9340/9341 GLCD driver.

When I found the HardwareSPI SD-Card thread, I thought I would post the link.


Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 11, 2014, 08:45 pm
I've been focussing on getting I2C working, as this was my primary reason for using the STM32, but I will now take a look at SPI.

From what I have read in passing, it does work, and I saw that mrbrunette did some tests.

However he was using the maple HardwareSPI class.

I want to write a wrapper for this, so that existing libs e.g SD will work without modification, but I'm not sure how practical a wrapper class is.
But in theory I can't see why it can't be done.



On a totally different issue..

While looking at I2C speed, I noticed that digitalWrite contains an if statement to check if the pin number requested is in the valid range.

I'm not sure if the Arduino AVR or Due (SAM) boards have this check.
As the main advantage of these chips is performance, it seem a bit odd to waste clock cycles testing for array indexes into lookup tables.
I.e if you make a mistake like that in your own code it will crash or hang, so I don't see why digitalWrite should have that protection.

Also digitalWrite does bit shifting and other arithmetic operations which will take clock cycles, which seems odd considering there is already one lookup table between the maple PIN numbers I.e I think they map D0 D1 etc, but I will need to double check.

I'd have thought that it should be possible to directly map something like D5 to PA4 (or whatever the mapping is), and not have to do further shifting operations.


Anyway, if I make a copy of digitalWrite inside Wire.cpp and do the range checking and arithmetic operations to get the real PIN numbers, then store these in the class, as private properties.
I think I should be able to get I2C up to at least 400khz.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 11, 2014, 09:02 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
I'd have thought that it should be possible to directly map something like D5 to PA4 (or whatever the mapping is), and not have to do further shifting operations.
Is not the reason the pin mappings on the Arduino so convoluted is because Arduino allows the user to use Int variables for the Pin number?  Just mapping Port/Pin to a name would only require one matrix.

On the SPI, I got a clean compile of the ST7735 graphics library from Adafruit with changes for STM32 Maple flavor... using the MapleIDE.  I have not attached a display, I am only going for a clean compile right now but hopefully I will be able to test on a 128x128 display soon.
Representative TFT GLCD for the lib are:

 ----> http://www.adafruit.com/products/358 (http://www.adafruit.com/products/358)
         as well as Adafruit raw 1.8" TFT display
 ----> http://www.adafruit.com/products/618 (http://www.adafruit.com/products/618)

Then, I'd like to get the ILI9341 controller working with 240x320

Ray
Title: digitalWrite
Post by: rogerClark on Nov 11, 2014, 11:14 pm
@mrburnette

I've now looked at what the existing Arduino AVR and SAM cores do and what the Maple digitalWrite code does, and it not hugely different.

It does seem to do this for digital write


Code: [Select]


gpio_write_bit(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, val);

.....


static inline void gpio_write_bit(gpio_dev *dev, uint8 pin, uint8 val)
{
    val = !val;          /* "set" bits are lower than "reset" bits  */
    dev->regs->BSRR = (1U << pin) << (16 * val);
}


ie it has a lookup table (array of structs by the looks of it)

But it also does this

 
Code: [Select]
(1U << pin) << (16 * val);


So for I2C I could easily change what the calls to digital write do, and pre-define the values would be to set or reset SCL or SDA

i.e
It would save quite a few clock cycles as I can see it would take 1 clock for..

Lookup index into array
Lookup value inside struct (indexed from array)
Shift pin value, i.e 1U << pin
Shirt this value by (16 * val)  - the compilor will probably execute the 16 x mult as a shift as its probably quicker (but I can't be sure).

Saving 4 or 5 clock cycles in this sort of repetative code can be very important to speeding up things like I2C


Re: SPI

Ray.. Thanks
Let me know how you get on.

I was going to hook up a SD card last night (my time) but didnt get around to it, as I wanted to try a new version of a motion sensor lib (which didnt end up working correctly )

But I may try SD tonight.

I think the other SPI devices I have are NRF24L01, some Nokia displays 6110 I think, I have a RFID but I think its I2C as well as SPI and I cant remember which lib I used for it when I origanally tested it.

I have some OneWire temperature sensors to test with when I get chance, and I also have a temperature / humidity sensor  - but they are their own protocol which I think is bit banged by a special library. Umm they may not work, unless someone used micros() lets hope they did ;-)
Title: Re: SPI
Post by: mrburnette on Nov 12, 2014, 05:00 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
Ray.. Thanks
Let me know how you get on.
Argh!

After moving the no-error compile from MapleIDE to ...\Arduino\hardware\Maple... and adjusting some headers, I now have a single error with ArduinoIDE 1.5.7...

and I really hate this error... a vtable issue.

Code: [Select]

D:\Documents\Arduino\hardware\Maple\Maple\libraries\Adafruit_GFX/Adafruit_GFX.h:63:18: error: conflicting return type specified for 'virtual size_t Adafruit_GFX::write(uint8_t)'
   virtual size_t write(uint8_t);
                  ^
In file included from D:\Documents\Arduino\hardware\Maple\Maple\cores\maple/wirish/HardwareSerial.h:38:0,
                 from D:\Documents\Arduino\hardware\Maple\Maple\cores\maple/wirish/wirish.h:50,
                 from D:\Documents\Arduino\hardware\Maple\Maple\cores\maple/Arduino.h:30,
                 from D:\Documents\Arduino\hardware\Maple\Maple\libraries\Adafruit_GFX/Adafruit_GFX.h:5,
                 from graphicstest.pde:31:
D:\Documents\Arduino\hardware\Maple\Maple\cores\maple/wirish/Print.h:40:18: error:   overriding 'virtual void Print::write(uint8_t)'
     virtual void write(uint8_t ch) = 0;
                  ^


I suspect that after a Mexican lunch with my wife and a couple of Margaritas, I will see if I can educate myself enough to correct the problem.  Right now, I'm just calling this a work-in-progress.  (My idea of a port is a good Vinho do Porto)


Ray
Title: Lib maple compatibility issues
Post by: rogerClark on Nov 12, 2014, 08:14 pm
Hi Ray

I took a look at compiling the SD example that comes with the IDE, but it soon became clear that some changes to the existing core code needs to occur.

SD can't access print.h because its in a non standard location, as all the core headers are in a folder called wirish.

So throwing caution to the wind, I moved all the headers out on the wirish folder and put them in the same folder as the core cpp files. (Which is the structure Arduino 1.0 and 1.5.x)

Using Notepad++ I did a multi file, find and replace to remove the wirish folder path from the cpp and header files in question.

And surprisingly when I compiled and ran the i2cscanner it worked fine!

Also my other i2c test program worked ok.

I also manually changed the includes from for example <print.h> to "print.h" to match the AVR and SAM versions.

And it still compiled after this change.

However when I tried to compile the CardInfo demo from SD , it failed as the STM32 libraries don't have an SPI folder with SPI.cpp and SPI.h, so the IDE picked up the AVR SD lib I think, which of course would not compile.

I started to make SPI files for STM32, however I ran out of time yesterday.

I have just copied the SAM Due files, and am initially just going to comment out the SAM specified code and leave empty functions, to confirm that I can get it to compile.

If that works, I am going to call the Hardware SPI class from those functions, but I suspect its several hours work.


Btw.

Re your compile error.

Although I made some changes to print.cpp it looks like the functions are still not all compatible with the Arduino 1.0 or later API.

however I doubt that it would be hard to correct the problem, as its easy to compare the AVR or SAM version of print to the Maple version that I already modified a bit.

One thing I noticed a while ago was that the print functions now return the size of the data they have written, but the maple versions return void.

So I had contemplated copying the SAM print.cpp and h to the STM32 code, and then just merge in the 2 functions from stm32 version, which actually write the data to the hardware.

But as everything else I compiled didn't have an issue with the return type, it didn't seem a problem that needed to be fixed urgently, until now;-)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 12, 2014, 10:53 pm
Ray

I did a quick hack job on my copies of the SAM SPI files (needed for #include <SPI.h>) and they compile (but with no functionality at the moment)

However, when I tried to compile cardinfo.ino I get what I think is the same error as you, which is being caused by a problem with print::write

However I don't have time until later today to figure out quite what the problem is.

The error says something about Print not being derived from the File stream class. But I've checked the SAM version of print and neither it or the STM32 is derived from File stream

I think one of the print write methods is defined as virtual, so its possibly something to do with either that and its final implementation, or possibly something to do with the method signature i.e the return type being void rather than the size of bytes written.

But I'm currently not sure precisely whats going on

The other thing which I now get an error about is HardwareSPI which is odd, as I can't see how the STM Hardware SPI could get included, as I'm using an example from the core Arduino IDE

Anyway, I'l take a look again this evening.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 12, 2014, 11:09 pm
I'm still reading everything Roger, I dont really understand it all, but I am sure it will sink in eventually !
Thank you for all the spade work you are putting in here :)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 13, 2014, 12:27 am
@mcnobby

Well, I don't totally understand whats going on either ;-)

I am a professional developer, but I've not done any commercial C or C++ work for a while.
I do C# and Objective C from time to time, which are similar but not quite the same.


The thing is... That LeafLabs team made some odd decisions when they developed the code, like putting all the core headers in a sub folder, when even the Arduino version at that time didn't have them in a sub folder.

I'm just a bit loathed to tear into it and make wholesale changes, when I don't understand why things were done in a certain way, in the first place. I usually assume there is a reason that people coded things in a specific way, but perhaps this isn't always true.

Its a shame the not too many other people, e.g. people who have worked on other device ports, are interested in the STM32, as I'm sure they'd have a lot more insight.

But I'll keep plodding on when I get chance.


My core aim was to get I2C working, which I've now achieved and I'm only doing SPI as a matter of interest really.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 13, 2014, 01:40 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
So throwing caution to the wind, I moved all the headers out on the wirish folder and put them in the same folder as the core cpp files. (Which is the structure Arduino 1.0 and 1.5.x)

Using Notepad++ I did a multi file, find and replace to remove the wirish folder path from the cpp and header files in question.
And surprisingly when I compiled and ran the i2cscanner it worked fine!
Also my other i2c test program worked ok.
WhooHoo!

Quote
LeafLabs team made some odd decisions when they developed the code, like putting all the core headers in a sub folder
And I read a post on their site from a Leaflabs employee stating that they have no intention to change this!  But, no dialog to defend the rationale or explain the thinking.

Ray
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 13, 2014, 02:52 am
Quote
I'm just a bit loathed to tear into it and make wholesale changes
Keep in mind that Maple was VERY early in the Arduino development cycle; one of the first non-megaXX8 designs, way before non-AVR chips and even before "variant"; what seemed like (or was) a reasonable idea at the time may be very different than what would make sense NOW, given the 1.5.x "platforms" architecture.
(which ... I don't think anyone has actually done a 3rd party board for yet...)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 13, 2014, 08:48 am
Its a shame the not too many other people, e.g. people who have worked on other device ports, are interested in the STM32, as I'm sure they'd have a lot more insight.
I am sure that this is going to catch on, I am still due to test mine over serial, and when my JTAG arrives.
All it needs is the right projects and topic headers to catch peoples attention

I already have project ideas for the Mapleduino (snigger, again) but may need to develop them within the forum as I have never worked with such a beast !

Incidentally (and this sounds stupid me saying it) - what does the '32bit' mean ?? I know its to do with math, but can someone explain in laymans terms please
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 13, 2014, 10:17 am
Quote
Incidentally (and this sounds stupid me saying it) - what does the '32bit' mean ?? I know its to do with math, but can someone explain in laymans terms please
Normally this refers to the internal architecture of the IC

i.e rather than a 8 bit wide data path between the internal parts of the CPU its 32 bits wide, and probably things like the arithmetic logic unit and all the clever stuff in the chip is 32 bits wide, so calculations etc can be done quickr.



Re: SPI etc

Looking at the issues that MrBrunette has seen, they are definately the return types on the write methods in the print and other classes (mainly the print class)

So I've just spent about an hour, changing the return type to size_t to match what the SD lib now expects.

However although it fixes that issue there is something more serious going wrong with inclusion of core AVR / SAM files rather than STM32 SPI files :-(

I'll need to investigate to work out why this is happening, it could be a bug / feature in the IDE... But I hope not..
Title: Lots more stuff to do before I can get SPI integrated :-(
Post by: rogerClark on Nov 13, 2014, 11:46 am
Guys,

I've just been trawling through compile error after compile error, with the SPI stuff.

The STM code was missing Steam.cpp and Stream.h and the return types of all the print functions needed to be changed to size_t

And I've now found there are new functions in print.h (which hopefully will be OK with the code I copied from the AVR core)

But I suppose this does help general compatibility if I add in the missing files,


However I'm still far from getting cardinfo.ino to even compile with no functionality in the SPI.cpp i.e just empty stub functions.





Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 13, 2014, 02:24 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
I've just been trawling through compile error after compile error, with the SPI stuff.

The STM code was missing Steam.cpp and Stream.h and the return types of all the print functions needed to be changed to size_t

And I've now found there are new functions in print.h (which hopefully will be OK with the code I copied from the AVR core)
Congrats.  I did not see that deficiency in the error messages I was getting from the compile.  However, it is a step forward and your effort is much appreciated.

I'll pull a new copy from your Github.
UPDATE... Oops... I don't think the repo has been updated.  Are you uploading a "working" version and moving changes to the public repo after validating?



Ray
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 13, 2014, 02:41 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
what does the '32bit' mean
Of course, rogerClark's explanation is correct.  It helps sometimes to back away just a little and think about those common 8-bit units with which we are familiar.  Data types in C can be 8, 16, 32: uint8_t, Int, Float.  In thinking about this, 8 bits would be the 'native" data type for storage... essentially a char.

As we walk up the technology data width, a 32-bit processor simply handles a 4-byte Float variable as the native data type.  An Int is 32 bit on ARM (vs Int on AVR which is 16 bit.)

So, in the ARM world:

Code: [Select]

Type Size in bits Natural alignment
char 8 1 (byte aligned)
short 16 2 (halfword aligned)
int 32 4 (word aligned)
long 32 4 (word aligned)
long long 64 4 (word aligned)
float 32 4 (word aligned)
double 64 4 (word aligned)
long double 64 4 (word aligned)
all pointers 32 4 (word aligned)
bool[1] 32 4 (word aligned)

[1] Applies to C++ only.


Essentially, what matters in the architecture is that "int", "long", "pointers", and 'float" are equally efficient moving from memory to the ALU.

Ray
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 13, 2014, 04:21 pm
Thanks Roger and Ray for that explaination, I thought it might be along those lines

So I guess my shape drawing routines (using sin, cos etc) will be faster because of the 32bit core of the STM32 rather than the 8bit core of the ATMega (removing the speed scaling of 16mhz to 72mhz of course) ??

Regards, Bob
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 13, 2014, 05:27 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Quote
So I guess my shape drawing routines (using sin, cos etc)
It's going to be fast... how fast will depend on code + compiler optimizations.  The STMF1 has both 16-bit instructions that are 1 clock cycle and has 32-bit instructions that are 1.5 clock cycles.  However, flash is on a 64-bit address bus... so the compiler makes a lots of assumptions.  A direct read from flash imposes 2 waitstates but instruction prefetch optimizes out most of the flash access penalty.

The AVR is 8-bit and is RISC with most instructions being 1 clock... just like the STM 16-bit instructions.  If the STM was 8-bit with a RISC instruction set, then 16MHz to 72MHz would be a 4.5x performance increase purely on clock.  You will not likely achieve a 4x in reality, IMO unless you used assembler and shy'd away from those 1.5 clock instructions.

Floating point will likely improve significantly in efficiency with the STMF1 but true performance will be depend on the IEEE library implementation and how well that maps into the ALU architecture for the STMF1 device.  I found this up on an STM forum for 32-bit/72MHz devices:
Quote
.
Add/Sub    33-43 cycles
Mul            36 cycles
Div            49-58 cycles
I think Nick Garmmon has a Prime Number Generator but I am not sure how real-world such an algorithm will be to compare generic drawing functions.  If you get around to testing when your hardware arrives, I'd love to see the numbers you get.  I need to search for Nick's algorithm to see if it will quickly port into the Maple.


Ray

Title: Re: What's this I found on eBay?
Post by: oric_dan on Nov 13, 2014, 06:07 pm
I did a quick hack job on my copies of the SAM SPI files (needed for #include <SPI.h>) and they compile (but with no functionality at the moment)

However, when I tried to compile cardinfo.ino I get what I think is the same error as you, which is being caused by a problem with print::write

However I don't have time until later today to figure out quite what the problem is.

The error says something about Print not being derived from the File stream class. But I've checked the SAM version of print and neither it or the STM32 is derived from File stream

I think one of the print write methods is defined as virtual, so its possibly something to do with either that and its final implementation, or possibly something to do with the method signature i.e the return type being void rather than the size of bytes written.

But I'm currently not sure precisely whats going on

The other thing which I now get an error about is HardwareSPI which is odd, as I can't see how the STM Hardware SPI could get included, as I'm using an example from the core Arduino IDE.
Roger, I haven't been following this thread, so sorry if I'm out of phase. As noted on another thread, the SD libraries included in ALL of the IDE versions, up to and including v.1.5.x, are 5-years out of date. However, you have a rare opportunity here in that the author of the SD libraries is not MIA like many others, but is constantly updating his libraries.

https://github.com/greiman/SdFat (https://github.com/greiman/SdFat)

Bill Greiman is present every day on the Storage section of this forum, so if you care to, you might post a msg over there about your issues.
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 13, 2014, 06:37 pm
i checked the official arduino sd demo as recently as last week with zero problems. why is there pressure to change something that works? what am i missing?
Title: Re: What's this I found on eBay?
Post by: oric_dan on Nov 13, 2014, 06:52 pm
i checked the official arduino sd demo as recently as last week with zero problems. why is there pressure to change something that works? what am i missing?
This isn't really my discussion, but there are at least 2 problems. One is that, the 5-YO libraries don't have support for new popular chips, such as the mega-1284. Secondly, take note of my last comments on reply#3 of the following thread, in regards using the SD read/write and listfiles examples together. My personal experience with "example" sketches is that maybe 95% are totally trivial, and poorly tested to boot.

http://forum.arduino.cc/index.php?topic=277769.0 (http://forum.arduino.cc/index.php?topic=277769.0)

Quote
NOTE: if you use IDE v.1.0.x through v.1.5.x SD library, remember they're all 5 years out of date, and do have some problems.

Eg, there are 2 example sketches that display the SD card files, listfiles and CardInfo, plus a couple of examples that show how to write and read files on the SD card. Well, it turns out [at least for me] that, the listfiles scheme is not compatible with the simple read/write operations, but the CardInfo scheme is ok. Specifically, listfiles no longer works once either read or write has been done, and I couldn't figure out how to fix it, so stay with the CardInfo scheme. Bizarre.
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 13, 2014, 08:43 pm
thanks for bringing that to my attention. i need to get out more. m1284 is one of my favorites but i can understand why massimo and gang are less than enthusiastic to support non-official platforms like that. cuts into the bottom line which is already hurting for sure.

chinese clones of supported chips also to blame for deteriorating support.

btw ive had better luck with these demos but thats probably because arduino is not my primary language. its mostly used to verify hardware and basic algorithms then switched over to winavr or for basic apps even avrasm. in the case of sd i found chans stuff quite useful.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 13, 2014, 09:44 pm
(arrggghhh.  I just spent ages posting a reply from my iPad and again, the forum has thown it away, I must remember the forum is broken)

Anyway to paraphrase what I've already spent half an hour typing ..

Ray.
I didn't upload because I thought the code may not work at all, i.e not even Serial working, but I"ve just done a test and the basics seem to be intact, but I can't test USBSerial, but it does seem to compile OK.




Re: Speed

For raw processing I guess the speed should be 72/16 as fast as the AVR boards and comparable to the Due ?

I just modified Nicks prime number
Took 247501 mS. Found 500 primes


This doesn't sound that last to me, but I'll need to run it on a Due and compare (see code below)

The real speed demons will be F4 based boards, as they can go at 180Mhz and have a floating point maths unit in the chip.




Re: SPI

AVR and SAM have their own implementations of SPI.c and SPI.h, I've just duplicated the SAM files and removed the code and just left empty methods, which I intend to implement using the HardwareSPI code that LeafLabs did, but apart from the changes in print and all headers needing to be moved (all core headers), and stream.cpp being missing, etc etc
There is some weirdness where I've had to define things like MOSI pin. I have temporarily done this in wirish.h to get rid of compile errors, but I know ultimately I'll need to track down why its even needed for this platform.

And currently I'm getting compile errors as if SPI is not being included in some places (I'm not sure quite whats going on)

I don't think the core SPI would need to change (i.e in the IDE as they have managed to get the Due to compile using this structure), but there still could be something in the IDE which is going to be a problem, its hard to tell right now.

Anyway. I better see if I send this if the forum accepts the post from my PC


Code: [Select]

// Prime number generator
//
// Author: Nick Gammon
// Date:   8th October 2013



const int SHOW_EVERY = 500;  // how often to echo a prime to the serial port

long candidate;
long found = 5; // Number we found
int count = found - 1;


void setup() {
  Serial.begin(115200);
 
  while (!Serial)
  {
  }
}

unsigned long start;
unsigned long lastShown;

void loop()
  {

  for (candidate = 3; candidate < 99999999; candidate += 2)
    showIfPrime (candidate);
 
  }  // end of loop

void showIfPrime (long num)
  {
 
  // we are already skipping odd numbers, now skip if divisible by 3
  if (num % 3 == 0)
    return;

  // Only have to check for divisible for the sqrt(number)
  long upper = sqrt(num) + 6;
 
  // Check if the number is divisible (start at 6 going up)
  for (long cnum = 6; cnum <= upper; cnum += 6)
    {
    if (num % (cnum - 1) == 0)
      return;
    if (num % (cnum + 1) == 0)
      return;
    }  // end of checking cnum-1, cnum+1

 // echo to serial port for validating
 if (++count >= SHOW_EVERY)
  {
  Serial.println (" primes.");
  Serial.print(candidate);
  Serial.print(" is prime. Took ");
  Serial.print(millis () - start);
  Serial.print (" mS. Found ");
  Serial.print (found);
  Serial.println (" primes.");
  start = millis ();
  count = 0;
  }

  found++;

  // delay until interval is up
  // (this absorbs the calculation time)
  while (millis () - lastShown < SHOW_EVERY)
    { }
   
  char buf [10];

  if (found%10==0)
  {
    Serial.print(".");
  }
  lastShown = millis ();
 
}  // end of showIfPrime
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 13, 2014, 09:51 pm
Re: Prime number

I just ran it on a Uno and its took precisely the same about of time

Quote
3571 is prime. Took 247502 mS. Found 500 primes.
Very odd. and suspicious

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 13, 2014, 09:55 pm
Ray

If you want my latest experimental version its here

http://rogerclark.net/downloads/Arduino_STM32.zip

It does seem to compile and run normally

But I can't test Serial USB on Maple as mine have not arrived yet

Serial via a USB to Serial adaptor works fine


SPI does compile (with no functionality) but CardInfo.ino doesnt

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 13, 2014, 10:01 pm
I just had a thought about the apparent slow speed of my board

I wonder if the PLL clock multiplier needs to be set, as I'm not using a bootloader perhaps its set to 1 x instead of 8 x the external clock (which I think is 8Mhz)

But delay etc are all working correctly


which would imply that the speed is correct somewhere.

In the boards.txt I have

maple_STM32.build.f_cpu=72000000L

And delay(1000) seems to delay 1 second


ummm

Very odd that I seem to get identical performace as a Uno.


I must be doing something really stupid
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 14, 2014, 03:26 pm
my stm32 card has arrived so it seemed like a good time to install and checkout 1.5 (1.5.8 ) for the first time. no maple stuff yet, just things that ive verified work fine under 1.0.5. trying the known good sd sketch this pops up:

G:\arduino-1.5.8\libraries\SD\src\utility\Sd2Card.cpp:26:17: fatal error: SPI.h: No such file or directory
#include <SPI.h>
                ^

do i need to locate and install 1.5.7? search out and install a new spi.h? fix sd2card.cpp? change the main sd sketch? is this a bug in all 1.5? something related to paul stoffregen changes?

ive been using original arduino from the start and compiled thousands of sketches but have been avoiding 1.5 suspecting just these kind of issues. any help here would be appreciated.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 14, 2014, 03:55 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Re: Prime number
I just ran it on a Uno and its took precisely the same about of time
Very odd. and suspicious
On the Baite Maple Mini clone, I modified your exemple to use SerialUSB and I used TeraTerm to manage the handshake; that is, SerialUSB.available()

If your results are strange, mine are mor' strange!

Here are my results:
Code: [Select]

.................................................. primes.
3571 is prime. Took 286528 mS. Found 500 primes.
.................................................. primes.
7919 is prime. Took 249987 mS. Found 1000 primes.
.................................................. primes.
12553 is prime. Took 249987 mS. Found 1500 primes.
.................................................. primes.
17389 is prime. Took 249986 mS. Found 2000 primes.
.................................................. primes.
22307 is prime. Took 249986 mS. Found 2500 primes.
.............................................


Edited for SerialUSB
Code: [Select]
// Prime number generator
//
// Author: Nick Gammon
// Date:   8th October 2013



const int SHOW_EVERY = 500;  // how often to echo a prime to the serial port

long candidate;
long found = 5; // Number we found
int count = found - 1;


void setup() {
  //Serial.begin(115200);
 
  while (!SerialUSB.available())
  {
  }
}

unsigned long start;
unsigned long lastShown;

void loop()
  {

  for (candidate = 3; candidate < 99999999; candidate += 2)
    showIfPrime (candidate);
 
  }  // end of loop

void showIfPrime (long num)
  {
 
  // we are already skipping odd numbers, now skip if divisible by 3
  if (num % 3 == 0)
    return;

  // Only have to check for divisible for the sqrt(number)
  long upper = sqrt(num) + 6;
 
  // Check if the number is divisible (start at 6 going up)
  for (long cnum = 6; cnum <= upper; cnum += 6)
    {
    if (num % (cnum - 1) == 0)
      return;
    if (num % (cnum + 1) == 0)
      return;
    }  // end of checking cnum-1, cnum+1

 // echo to serial port for validating
 if (++count >= SHOW_EVERY)
  {
  SerialUSB.println (" primes.");
  SerialUSB.print(candidate);
  SerialUSB.print(" is prime. Took ");
  SerialUSB.print(millis () - start);
  SerialUSB.print (" mS. Found ");
  SerialUSB.print (found);
  SerialUSB.println (" primes.");
  start = millis ();
  count = 0;
  }

  found++;

  // delay until interval is up
  // (this absorbs the calculation time)
  while (millis () - lastShown < SHOW_EVERY)
    { }
   
  char buf [10];

  if (found%10==0)
  {
    SerialUSB.print(".");
  }
  lastShown = millis ();
 
}  // end of showIfPrime


Here is the upload process via serial USB:
Quote
maple_loader v0.1
Resetting to bootloader via DTR pulse
Searching for DFU device [1EAF:0003]...
Found it!

Opening USB Device 0x1eaf:0x0003...
Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=1, name="DFU Program FLASH 0x08005000"
Setting Configuration 1...
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
bytes_per_hash=368
Starting download: [##################################################] finished!
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 14, 2014, 04:09 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


my stm32 card has arrived so it seemed like a good time to install and checkout 1.5 (1.5.8 ) for the first time. no maple stuff yet, just things that ive verified work fine under 1.0.5. trying the known good sd sketch this pops up:

G:\arduino-1.5.8\libraries\SD\src\utility\Sd2Card.cpp:26:17: fatal error: SPI.h: No such file or directory
#include <SPI.h>
                ^

do i need to locate and install 1.5.7? search out and install a new spi.h? fix sd2card.cpp? change the main sd sketch? is this a bug in all 1.5? something related to paul stoffregen changes?

ive been using original arduino from the start and compiled thousands of sketches but have been avoiding 1.5 suspecting just these kind of issues. any help here would be appreciated.
I'm runnin 1.5.7 and I do not have the SD\src\utility\ structure!  I did load and process C:\Program Files (x86)\Arduino_157\libraries\SD\examples\CardInfo and it worked OK.

Ray
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 14, 2014, 05:11 pm
I just ran it on a Uno and its took precisely the same about of time
Very odd. and suspicious
Is there anyway of being able to print out F_CPU just to make sure it HAS been set ?

Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 14, 2014, 05:26 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Is there anyway of being able to print out F_CPU just to make sure it HAS been set ?
F_CPU is set in the boards.txt file as an environmental. 
maple_mini.build.f_cpu=72000000L
During the compile process, platform.txt passes this directly to the compiler runline as:
-DF_CPU={build.f_cpu}

The 4 general purpose timers appear to not be utilized directly for the running sketch, rather the systick appears to be the controlling timer for the main loop.
SYSTICK_CSR_CLKSOURCE_CORE
and in systick.h the system uptime is directly reflected from this timer:
/**
 * @brief Returns the system uptime, in milliseconds.
 */
static inline uint32 systick_uptime(void) {
    return systick_uptime_millis;
}


Unless I am missing something elementary, systick is running at 72MHz.

Ray
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 14, 2014, 05:27 pm
Just been googling for "STM32103CBT6 72mhz problem" and found this....

http://www.rcgroups.com/forums/showatt.php?attachmentid=5117674&d=1346246444 (http://www.rcgroups.com/forums/showatt.php?attachmentid=5117674&d=1346246444)

in the attachment it talks about  #define SYSCLK_FREQ_72MHz  72000000

this info is from a radio control group, helicopters I guess ...

anyway, just wondered if it helps

.. also I found this...

Code: [Select]
But, there's also another way to squeeze even more horsepower out of the STM32F103. The clock speed can be multiplied by an on-board Phase-Locked Loop (PLL) to up to 72MHz. (Right now, the 16MHz oscillator sets the clock speed directly.) I've never even bothered to try turning on the PLL, but now seemed like a good time to see what it would do. For some yet-unknown reason, I was only able to multiply my 16MHz oscillator by as much as 3.5 (or rather, divide it by two and then multiply it by seven...don't ask). That gives me 56MHz. I'm not sure why it won't go higher than that, but I suspect some hidden clock speed limit on a peripheral. But I tracked down all the obvious ones, and none were overclocked. Anyway, here's what the fast loop processor utilization looks like at 56MHz:


three quaters of the way down this page... (http://scolton.blogspot.co.uk/2011/11/ah-software-optimization-my-old-friend.html)
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 14, 2014, 05:34 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


<...>
in the attachment it talks about  #define SYSCLK_FREQ_72MHz  72000000

this info is from a radio control group, helicopters I guess ...
anyway, just wondered if it helps

three quaters of the way down this page... (http://scolton.blogspot.co.uk/2011/11/ah-software-optimization-my-old-friend.html)
OK, I found this page: rcc.html (http://static.leaflabs.com/pub/leaflabs/maple-docs/snapshots/2012-09-04/libmaple/api/rcc.html)

I am beginning to think the Maple Mini is running the 8.000 Crystal and using the PLL to 2x so that the "arduino compatibility" timing and stuff all works without mods.  Definitely need to dig deeper...  Nope... Maple's forums indicate the default setup is 72 MHz and members have compiled and tested "empty loops" against other environments such as Arduino.  So, something else is happening with the Prime sketch.


Ray


Update:

For grins, I ran the same Prime sketch through the Maple 0.0.12 version of their GUI and the Prime times were the same:
Quote
.................................................. primes.
3571 is prime. Took 257033 mS. Found 500 primes.
.................................................. primes.
7919 is prime. Took 249987 mS. Found 1000 primes.
.................................................. primes.
12553 is prime. Took 249987 mS. Found 1500 primes.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 14, 2014, 05:45 pm
OK, I found this page: rcc.html (http://static.leaflabs.com/pub/leaflabs/maple-docs/snapshots/2012-09-04/libmaple/api/rcc.html)
Good find Ray, Im a bit out of my depth with this, but maybe someone could shed more light on it.

It would obviously be good to run 'the Beast' at full chat since thats the main reason why this topic started :)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 14, 2014, 05:51 pm
Or even perhaps 128mHz !! (http://blog.tkjelectronics.dk/2010/02/stm32-overclocking/)

and HERE (http://forums.leaflabs.com/topic.php?id=31)
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 14, 2014, 06:31 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Or even perhaps 128mHz !! (http://blog.tkjelectronics.dk/2010/02/stm32-overclocking/)

and HERE (http://forums.leaflabs.com/topic.php?id=31)
Unfortunately, that advice was for the "old" Maple IDE... they reworked it (before they dropped it...)
Here is the bottom-line from Maple:
Quote
That code is very old. rcc.h has been heavily reworked since then, so you'll have to port the old libmaple style of register access, individual register addresses #defined as numbers (e.g. RCC_CR) and manipulated with macros that cast them to pointers (__read(), __write()) to the new style, which is explained here:

http://leaflabs.com/docs/libmaple/overview.html

Given that I have no idea about the practical consequences of overclocking the board, I'll just say that if you attempt this, good luck, have fun, I hope your Maple doesn't break.
BUT - The take-away here is that the Maple & Maple Mini boards do run at 72 MHz at the core.  Other things are obviously happening around the Arduino compatibility.  For now, my head hurts and I think I will revive this topic when rogerClark completes his porting of the core.  Which is to say, maybe this is a tangent at the moment?  Although a perplexing one...

Ray
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 14, 2014, 06:58 pm
You are probably right Ray :)

I had a look look at one of the links you sent, and this is very interesting and answers alot of questions

Maple-Arduin Compatibility (http://static.leaflabs.com/pub/leaflabs/maple-docs/snapshots/2012-09-04/arduino-compatibility.html)

EDIT: actually I found it a fantastic read, I am sure Roger will too :)
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 14, 2014, 07:39 pm
I'm runnin 1.5.7 and I do not have the SD\src\utility\ structure!  I did load and process C:\Program Files (x86)\Arduino_157\libraries\SD\examples\CardInfo and it worked OK.

Ray
thanks. apparently 1.5.8 has been "improved" to the point the spi no longer works.  1.5.8 is the official version now but i will try to find and install 1.5.7 and run cardinfo instead of the standard sd demo. anything to get my spi feet on the ground again.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 14, 2014, 08:34 pm
@john1993

There isn't SPI support in my version, that will just work out if the box with examples that need SPI.h

SPI is supposed to work, but the maple class is HardwareSPI, so you'd need to copy and modify libs to use that class.

I have started to work on a version that has SPI.h , and but its taking quiet a lot of work, and all I have managed to do so far is a major reorganisation of the header files and added stream.cpp and changes to the print class

The zip file I put on my website has the reorganisation but the SPI cpp just contains stub functions and I'm still having issues getting some IDE libs to include the stm32 SPI.h but I'm not going to have time to look at this again until tomorrow.


I'm using 1.5.7 and have not updated to 1.5.8.  So I can't comment on compatibility. I will give it a try tomorrow.

Definitely try 1.5.7. Things seem to work, apart from SPI ;-)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 14, 2014, 08:43 pm
Ray

Thanks for you PM.

If you email or pm me you ino I can take look on Sunday my time.

Perhaps John or WestFW or oric dan  can give me some feedback on moving the headers out of the folder called wirish

I know this may be initially a problem, and may require some changes to the maple examples, but as the standard arduino examples and stuff in the Arduino playground etc etc, don't include headers like print.cpp from a folder called wirish, I think that its better to bite the bullet now, and make the folder structure the same as the AVR and SAM cores.

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 14, 2014, 08:52 pm
Re processor speed

I've not had chance to try anything, but I have looked at the clock setup stuff, and as far as I can tell, the clock multiplier should be setup even in the version without the bootloader.

The bootloader has a function to set the clock multiplier, but there is also code to do this before main() is run.

One test, I will do is reduce the clock multiplier and see if it goes slower, this should be a safe test.
I did see the over clocking stuff, but unless you keep the chip cool this cold cause a crash, so I will try the other way just to see what happens.


I know the double type is 64 bits, which is one of the reasons I want to use this device, I wasn't aware that int was 32 bit.

So perhaps the reason that the prime number test doesn't seem fast is that it could be using doubles where on AVR it uses float.

I will try to re code it to force use of specific types e.g use float.

E.g perhaps  modulus is double not float hence perhaps slower than on avr.

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 14, 2014, 09:14 pm
@john1993
There isn't SPI support in my version, that will just work out if the box
yes. ive gone through this thread a few times now and have a pretty good idea of project status. afaik serial and i2c are probably under control which is quite an accomplishment.

my problem is i cant get spi to work in the regular non-maple version. the sd demo works fine in 1.05 but wont even compile with 1.5.8. im going to follow mrburnetts footsteps and try cardinfo instead of the read/write demo and go back to previous ide just to see if i can get some hint of spi function out of standard 1.5.
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 14, 2014, 09:34 pm
Perhaps John or WestFW or oric dan  can give me some feedback on moving the headers out of the folder called wirish
having only a little experience regarding arduino environment i know bill is orders of magnitude ahead of me in that department. the experts here have done such a great job that even with with m1284, tiny13, etc there never was any big need for me to get involved at that level. raw winavr is more my territory.

however this new direction for ardunio has me excited to the point id be willing to learn the ins and outs just to provide any help i can. first i need to get some basic features like i2c and spi working for the regular non-stm 1.5 and atm this is not going so well. im not giving up though and at some point do hope to be in a position to contribute.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 14, 2014, 09:58 pm
Re: Speed

Just wrote a quick test to see how fast this runs

Code: [Select]
digitalWrite(PC13,LOW);
digitalWrite(PC13,HIGH);


and its outputting at just under 1Mhz, so either its taking something like 40 clock cycles to do a digital write, or my board config is not running at 72Mhz

(I have an oscilloscope to look at this sort of stuff)

I don't have time to compare this with a Uno or a Due until later, but if anyone else could do this test e.g. on a Maple mini, I'd be interested to see the results.

I guess one other thing I could do is load the maple bootloader and then manually flash the program into the area above the bootloader to see if this is an issue with the clock multiple needing to be setup in the bootloader

I will also work out the code to directly access the hardware, but I don't have time to do that now.



Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 14, 2014, 10:01 pm
@john1993

I'm not sure if you are using Serial to USB adaptor (personally I think its the easiest way at the moment)

If so, just get a simple Blink + Serial.Println("Blink")  program working

I think you said you had some oneWire devices ?? 

If you could try OneWire of any other I2C devices that would be useful, as I've only tested I2C on 2 different devices (but both are now working fine)

There is no point trying SPI unless you feel like writing the code to go into the stub functions in my experimental build ;-)
(and even then there appear to be some include issues possibly because of incorrect #defines or missing #defines')

Thanks

Roger
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 15, 2014, 12:18 am
@john1993
I'm not sure if you are using Serial to USB adaptor (personally I think its the easiest way at the moment)
lol. i think those who have seen my posts in this forum last couple years (this thread too) know how i feel on that subject.

blink is working fine. its spi that wont compile under 1.5.8 giving those errors i attached earlier. looks like the brainiacs that put together latest 1.5 misplaced spi.h. for me theres little point in proceeding until i get that fixed so im just going to take a step back and duplicate mrburnettes successful setup when i get to my own computer after work.

imo 99% of the applications use serial, i2c, or spi. even though i do have some dallas devices for me they are a niche protocol and not important at this time.
Title: Re: order received
Post by: mrburnette on Nov 15, 2014, 02:10 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Positive report on AliExpress.

Received my 5 STL32 Maple mini which were ordered October 22 today. 
All well: 5 Baite clones in factory sealed antistatic bags.

Ray
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 15, 2014, 02:39 am
Quote
as far as I can tell, the clock multiplier should be setup even in the version without the bootloader.
Hmm.  A sketch should be able to READ the clock configuration.

It sounds like the Leaflabs people wrote up a lot of descriptions of their design philosophy.  It's all probably worth reading.  I wonder if the Due team read it :-(

I also have somewhat disconcerting memories of them needing to redesign the Maple as a 4-layer board to get reliable operation.  AFAIK, all of the low-cost boards we're looking at now are only two layers...

Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 15, 2014, 03:49 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

FYI:

I did not know the entire mbed source is online.
mbed sources (http://developer.mbed.org/users/mbed_official/code/mbed-src/)

I stumbled across above while sinking deeper in quicksand attempting to port Adafruit's ST7735 TFT graphic SPI stuff to STM32.  Which, I am going to see if I can utilize this embed lib for the masple inlieu of Ladyada's stuff.
code/ST7735_TFT/ (http://developer.mbed.org/users/smultron1977/code/ST7735_TFT/)

Ray
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 15, 2014, 03:53 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

...
I also have somewhat disconcerting memories of them needing to redesign the Maple as a 4-layer board to get reliable operation.  AFAIK, all of the low-cost boards we're looking at now are only two layers...

Yep, Maple Mini is 2 layers
https://github.com/LeafGrass/Maple-mini-r2-evolution-board (https://github.com/LeafGrass/Maple-mini-r2-evolution-board)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 06:40 am
@john1993

SPI won't compile because in the version on my GitHub repo there is no SPI folder, as LeafLabs didnt write a directly compatible SPI class.

They wrote a class called HardwareSPI and put it in a different location (not in the libraries folder where SPI is normally located)

So I've been working on making the Maple code compatible with the Arduino programs that use SPI.h

However there were quite a few changes, and I have not finished, so I've not updated the GitHub repo, as I still cant get a clean compile of Cardinfo.ino even with just stub functions in the SPI folder

Its probably going to be a while before I can get this to work, as pressure of work etc, means I can only at most spend about 1 hour a day on this.

If you want you can download the latest version, which is close to compiling, and has lots of changes that will help. But its definitely not complete
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 15, 2014, 11:24 am
@john1993

SPI won't compile because in the version on my GitHub repo there is no SPI folder, as LeafLabs didnt write a directly compatible SPI class.
i havent made any attempt to make use of your files yet but the reason my non-maple standard 1.5.8 wont compile is because in that version spi.h is missing or in the wrong place for Sd2Card.cpp. the solution may be for me to go back to 1.5.7 or switch to cardinfo instead of the sd demo.

atm im more interested in how they screwed up the newest release or if its something i did wrong than actually fixing the problem.

now that i have an stm32 board ill be in a good position to try your maple extension but first need to get the normal distribution working. maybe you will have spi by then but no matter what ill be very impressed if the serial and i2c runs on my end.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 11:26 am
Finally got round to plugging in and testing my STM32 !!



I think I downloaded the suppository a few weeks back, and I have an entry in boards.txt which I also think may be right too. I am using 1.5.8

plugged in my usb->serial
TX -> rx1
RX -> tx1
5v-> VCC
0v -> gnd

when plugged in my board does this..
- flashes fast for ~1sec
- flashes slower for ~2sec
- flashes with a period of ~2sec 80% on 20% off

pressing RESET kicks the whole flashing malarkey off again

after rest, if I hold BUTTON2, then it looks like it goes into a different mode, the bootloader mode ? it has ~300ms period 50% on/off

I have tried to upload a simple bit of code, and I get this response (MEDIUM_DENSITY waffle removed)

Code: [Select]
<command-line>:0:0: note: this is the location of the previous definition

Sketch uses 10,404 bytes (9%) of program storage space. Maximum is 108,000 bytes.
COM16: No error
stm32flash - http://stm32flash.googlecode.com/

Using Parser : Raw BINARY


unplugging EITHER of the serial leads makes no difference as it always seems to report COM16: no error

any advise chaps ??
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 11:27 am
Roger, I cant find that link to your blog anywhere... could you repost it please
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 11:44 am
The link to my blog is

http://www.rogerclark.net/stm32f103-and-maple-maple-mini-with-arduino-1-5-x-ide/ (http://www.rogerclark.net/stm32f103-and-maple-maple-mini-with-arduino-1-5-x-ide/)


I don't have a maple so I'm only doing this from the technical details

However

If you press the reset button on the Maple I know it flashes quickly a few times than flashes slower continuously

This is Maple Bootloader mode and you can't upload if its flashing

Try holding the other button down, while tapping reset

Then release the other button

This should stop the led flashing as its put the chip into its internal Serial upload mode

Then try uploading something

Note. I have found occasionally that the upload doesn't work, in which case do the same button pressing procedure

And occasionally the IDE has totally confused the uploader, and I have had to restart the IDE (I can't remember what the error message is, I will try to write it down next time)


Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 11:47 am
Thanks ROger, I think I know what I have done wrong

I grab your latest repo and just dumped it in the hardware directory of my 1.5.8
I think I should have maybe created a new 1.5.8 and put the drivers/example/stmxx../tools into the right places

Is that right ? or do I just merge the new files into the old IDE files ?

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 11:50 am
Guys

I think the speed thing with the prime number program was a complete red herring.

And I got these results


On the Arduino Due I got these results 10000 primes in 73344 mS
On the STM32 10000 primes in 118372 mS



for this

Code: [Select]
unsigned long startTime=0;

void setup() {
  Serial.begin(115200);
  
  startTime=millis();
   long n=10000, i = 3, count, c;
  
 
   for ( count = 2 ; count <= n ;  )
   {
      for ( c = 2 ; c <= i - 1 ; c++ )
      {
         if ( i%c == 0 )
            break;
      }
      if ( c == i )
      {
        // Serial.println(i);
         count++;
      }
      i++;
   }
  
  
   Serial.println(--count);Serial.println(" primes in");
   Serial.print(millis()-startTime); Serial.print(" mS");
 
}


void loop()
{
}


Its strange that its significantly slower than the Due, but I'm not sure if the Due uses floats of doubles

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 11:51 am
MCNobby

I used 1.5.7

I can't comment on 1.5.8, though I think larry said it worked for Blink

You copy my repo files to

mydocuments/ arduino/hardware

i.e not in program files

reboot the IDE

You should see the new boards list

pick the last board in the list if you are using usb to serial

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 12:01 pm
Ta, done all that, not sure what else I am doing wrong, but it still says

Code: [Select]
Sketch uses 10,428 bytes (9%) of program storage space. Maximum is 108,000 bytes.
COM16: No error
stm32flash - http://stm32flash.googlecode.com/

Using Parser : Raw BINARY


no real errors, and the led is still flashing at a medium speed, so no change

I didnt even see and data passing through the usb->serial as the rx/tx leds didnt flash

hmmmm
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 12:10 pm
If they led is flashing you are not in serial bootloader mode :-(

Did you try the button press sequence I described.

I don't have any maple minis yet, so I don't know which button is which, I presume it written on the board

Btw

To into preferences in the file menu and tick verbose for compile and upload

In verbose you definitely see progress percentages displayed in red.

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 12:18 pm
If they led is flashing you are not in serial bootloader mode :-(

Did you try the button press sequence I described.
I cant seem to find that info... I have tried all manner of button pressing and get the same flasshes as described above, so I am not sure what flashes to see if its in booty mode
Quote
I don't have any maple minis yet, so I don't know which button is which, I presume it written on the board
I have a button marked RESET and a button marked BUTTON#32
(I have one of the long thinner blue boards you showed in your blog)
Quote
To into preferences in the file menu and tick verbose for compile and upload
In verbose you definitely see progress percentages displayed in red.
I shall try that now. Ta
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 12:25 pm
Mcnobby

Ah

Does your board have jump links

If so, you need to move one of them to the other position, however I suspect you don't have the.

My board only has one button, but it has 2 jump links

I have to but the link closest to the edge of the board into the other position and press reset.

Can you post the link to your board eg on eBay,

However it's getting late here in Melbourne,  so I will probably need to look at your reply tomorrow

However Larry and ray may be online soon in the us and chillitronix is in the uk

Try pm ing chillitronix now, and ray or Larry later, or I will be back in at about 6 or 7 pm uk time , which is Sunday for me
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 12:28 pm
So, here is the weird thing... if I unplug my usb->serial and compile/upload, I still get this

Code: [Select]
Sketch uses 10,428 bytes (9%) of program storage space. Maximum is 108,000 bytes.
C:\Users\Bob\Documents\Arduino\hardware\Arduino_STM32-master/tools/win/serial_upload.bat COM16 1 1EAF:0003 C:\Users\Bob\AppData\Local\Temp\build4522254043527023042.tmp/Blink.cpp.bin
COM16: No error
stm32flash - http://stm32flash.googlecode.com/

Using Parser : Raw BINARY


I dont get that, my IDE cant even see I have got a device to upload through ?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 12:30 pm
Re Speed


I managed to get. 12mhz square wave out of the stm32, albeit I had to bypass digitalWrite and go direct to the hardware.

Well actually I still have some optimisations in can do, as the code still references the port address via a struct to find the correct register, so I suspect I may be able to go faster.

Knowing this, I will be able to modify I2C to go considerably faster, possibly over 1mhz
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 12:36 pm
Mcnobby

The IDE just calls an external program to do the upload

In this case it's the stm32flash

I have not looked to see if perhaps somehow the other uploaders return a status, which stm32flash won't as its not written specifically for the arduino IDE


Have you stopped it flashing.

It will not upload if the led is still flashing

Flashing means its still running code in the maple bootloader

But serial upload is a function built into the silicon on the chip,and there is no indication as far as I'm aware that its in this mode.

So if the led is flashing, its not ready to receive data
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 12:39 pm
Please post a link to the board you bought

Or post a photo

You may even have a variant no one else has...

I'm sure it can be made to receive data but you may need to do something else to it, e.g link one pin to 3.3v

What are the pin names on the board

Does it have names line pb9 or does it say d5 or miso etc

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 12:42 pm
Right got that :) thanks

I have doing some experimenting... it seemed to be a port issue.. I have tried to fix it, but 1.5.8 is not having it

I am going to try this on 1.5.4, but for the life of me I cant find the correct entry for boards.txt to copy over - I have looked at 1.5.8 boards.txt and there isnt an entry for the STM32, but yet I can select one of 4 options in the boards menu

I am trying to untangle my knickers.. I will trip.. and I will cut my knee !!
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 12:51 pm
THis was what I bought... (http://www.ebay.com/itm/111450858151)
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 15, 2014, 01:10 pm
i found the problem with 1.5.8. turns out programs written for previous arduino versions will not run under the new one (i hate that). including spi.h in addition to sd.h works.

so moving on your zip files were added to hardware and "stm32 to flash" was selected. then the stm32 is put into boot mode (reset with boot0 high). arduino blink from examples compiles and uploades w/o errors.

at first glance none of the io seems to be toggling. the board and tools are known good because stm led demo works. the example says pin 13. can you tell me what bit that is on the c8 chip?
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 01:23 pm
I have found a new mode: if I hold the button#32 down and press reset, all the flashing stops.

still no upload though, and no error reports either :(
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 01:27 pm
Mine is a Maple Mini - Made by BAITE part no. BTE14-D7 (or it could be 07)

I am pretty sure its the IDE config that isnt right, if I select any other board then I get comms errors, if I select the STM32 to flash it compiles and reports No Error, even with the USB->Serial board unplugged from the USB !!!!!

I think i'll hang the washing out ! :(
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 15, 2014, 01:30 pm
SUCCESS!!!!!

pc14 is toggling! i didnt notice first time through because i didnt wait long enough on each pin.

i cant tell you how exciting this is to have an arm board up and running so quickly and w/o fuss. thanks for achieving such a milestone in mcu technology. now to try i2c. lets dust off the old mp9050 and 24xx eeprom and see what the scanner says.
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 15, 2014, 01:37 pm
mcnobby, i have a strange feeling if you follow my steps from previous post you will succeed because we both have exactly the same stm32 chip. make sure you have a working usb/serial dongle and rx/tx are right. swap if in doubt.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 01:38 pm
John, could you tell me what you are using ? which version of IDE ? what you use for USB->Serial interface ? and what you have for your boards.txt entry for STM32

Please :)

So glad you have yours up and running (a bit envious actually) now I would like to get mine going to

Ta
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 01:41 pm
mcnobby, i have a strange feeling if you follow my steps from previous post you will succeed because we both have exactly the same stm32 chip. make sure you have a working usb/serial dongle and rx/tx are right. swap if in doubt.
I would imagine you are right John, I have been shuffling back and forth through over 400+ replies to this thread trying to get a handle on what to do next...

What I (we) need is a clear concise set of instructions of how (and where) to install the files we need, onto a proven IDE version, using interface/target board connections, and button presses to kick the bootloader into receiving

Its raining, I wont put the washing out now :(
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 15, 2014, 01:47 pm
my steps in post #408 are concise but rogers blog is very detailed. either way i think youll be up and running soon. its quite a thrill to see how easy it can be to program an arm thanks to roger and team arduino.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 02:48 pm
Yeah Cheers, John, but I am still missing something but cant see what it is

really :(
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 15, 2014, 03:15 pm
do you know exactly where things are going wrong/ iirc from your older post the compile was ok but download is the problem. if thats the case you can try another method. hunt down the bin file and use stm flash loader demonstrator to program the chip. ive tried both methods and they work. i also ordered one of the jtag adapters which would be a 3rd method.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 06:07 pm
I've put it to bed for the day and going back to 8 bit for a while, might try again tomorrow, I have another PC, another IDE, and another day.. better luck I hope :)

The thing here is.. we all want our hardware/software to work first time dont we ?.. and one man is not quite as smart as the next man, and that man may also have mangled his IDE folders to the point of deletion ! I feel like a complete idiot not being able to sort this 'simple' task out !! :|
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 15, 2014, 07:16 pm
i know how you feel. i have zero patience and these things hardly ever go smooth for me. pure luck (and hard work from roger) this time.

i must have deleted and reinstalled the ide from scratch at least a hundred times over the years. today i was upset when previous source files didnt work with the new ide but must admit arduino guys do get many things right. i always choose zip over installer. then the ability to just copy that whole thing anywhere w/o regard to environment or dependencies is very nice.

pay close attention to rogers step 3 but note the path he used may not be the same for others. for example mine is "g:\ardunio-1.5.8\hardware\arduino". you have to go deep in his zip until you see stm32f1xx then copy all those folders. good luck.
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 15, 2014, 08:01 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


plugged in my usb->serial
TX -> rx1
RX -> tx1
5v-> VCC
0v -> gnd

when plugged in my board does this..
- flashes fast for ~1sec
- flashes slower for ~2sec
- flashes with a period of ~2sec 80% on 20% off

pressing RESET kicks the whole flashing malarkey off again
after rest, if I hold BUTTON2, then it looks like it goes into a different mode, the bootloader mode ? it has ~300ms period 50% on/off

I have tried to upload a simple bit of code, and I get this response (MEDIUM_DENSITY waffle removed)
<...>
unplugging EITHER of the serial leads makes no difference as it always seems to report COM16: no error
any advise chaps ??
You and I have the same board, BAITE.  The various bootloaders are explained here:
Maple bootloaders (http://leaflabs.com/docs/bootloader.html)

In the factory-serial mode, you will be uploading code and overwriting the USB bootloader.  To set this mode on the Mini, you need to (from the link above):
Quote
Step 2: Connect Maple Serial1 to your computer. There are a variety of ways of doing this. We use Sparkfun's FTDI breakout boards, but you could use another Maple, an Arduino, etc. - anything that allows your computer to communicate with the Maple you want to reprogram over a serial interface.

If you do use an FTDI breakout board, first make sure your Maple is disconnected from an external power source, be it battery, USB, or barrel jack. Then, connect the FTDI board's TX pin to Serial1's RX pin (labeled "RX1" on the silkscreen), FTDI RX to Serial1 TX (labeled "TX1"), FTDI ground to ground (labeled GND), and its 3.3V pin to Vin. On Maple Mini, you will also need to tie BOOT1 (pin 2) to ground.


More information on Serial1 is available here.

At this point, you're ready to plug the FTDI board into your computer (via USB).

Step 3: Run the built-in hardware serial bootloader[2]. Accomplish this using the following steps:

Press and hold the reset and BUT buttons.
Release the reset button without releasing BUT.
Release BUT.
At this point, if you followed the instructions correctly, the board will appear unresponsive - the LED won't blink, etc. Don't worry. This is the expected behavior for the serial bootloader.

Do not confuse the above steps, which run the built-in serial bootloader, with the steps for perpetual bootloader mode.
The implication that I read into the above is that the USB-serial should be in 3.3V mode, not 5V.

I am doing things completely differently and have not tried the above, but Roger is using it consistently through the Arduino 1.5.x IDE.  In my situation, I am using Windows 8.1 64-bit in "Test Mode" which can be preserved across reboots and power-cycles.  I show a serial driver as a virtual comm port when the Mini is attached.  During compile+download from Arduino, the serial line is pulsed (DTR) and the DFU comes online at which time the workstation and the Mini handshake over the DFU protocol.  After download, the Mini restarts and the sketch starts to run.  This process works most of the time although it is not 100%.  I think my workstation is "too fast" and sometimes the serial port does not enumerate.  A quick press on Reset always brings up the comm port.

The drivers for Windows seem stable on 8.1 64-bit but just do not present a digital signature - this can be fixed if someone wishes to invest... a quick Goggle and picking the first advertisement indicated about $223 per year for the privilege.  I suspect that a careful search may provide a less expensive alternative.

Ray
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 08:32 pm
Thanks Ray, I think I have tried all of that now, b ut its great to see all the info in one place..

when I compile & upload, I get this...

Code: [Select]
C:\Arduino155\hardware\Arduino_STM32/tools/win/serial_upload.bat COM19 1 1EAF:0003 C:\Users\Bob\AppData\Local\Temp\build7480047994650882628.tmp/sketch_nov15a.cpp.bin

Obviously, it doesnt upload, but I did try and run the info there in a dos window - no change

Then I had a look at what was happening in the serial_upload.bat file

Code: [Select]
@echo off
rem
rem parameters are:
rem Note: %~dp0 get path of this batch file, so path parameter is no longer required
cd %~dp0
rem: the two line below are needed to fix path issues with incorrect slashes before the bin file name
set str=%4
set str=%str:/=\%
stm32flash -g 0x8000000 -b 230400 -w %str% %1
rem C:\Python27\python.exe stm32loader.py -e -w -p %1 -g -b 230400  %str%


I am guessing the BIG BANG will happen at "stm32flash..." since I dont have python (and the line is remmed out)



Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 15, 2014, 08:36 pm
Sorry, I am taking up peoples time with this..
Im gonna go sit on the bench with the fat wheezy boys with notes from Matron !
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 09:26 pm
@all

I just looked at the 1.5.8 release notes about the changes and some stuff is could cause issues
(see bold below)

[ide]
* Find/Replace over multiple tabs (Erwin Ried, Fulvio Ieva)
* Fix wrong "Replace" behavior with empty "Find" field (Fulvio Ieva)
* A lot of command-line improvements (Matthijs Kooijman)
* Cursor is not moved when invoking autoformat

[libraries]
* SPI: added transaction API (Paul Stoffregen)
  https://github.com/arduino/Arduino/pull/2223
  https://groups.google.com/a/arduino.cc/forum/#!msg/developers/TuZLfjeZjDI/6deNjw3Y9m4J

* FileIO bridge: fixed wrong return value in File::size() for size >32768
* Updated Temboo to latest version
* Updates/Fix to various examples

[core]
* sam: "new" and "delete" do not bring in 50Kb of stdclib anymore
* Correct implementation of gcc specific internal functions (__cxa_guard_*) (Alexey Guseynov)
* Fix for upload problems on Leonardo (and derivative boards based on mega32u4)
* Small improvements on String class (Matthijs Kooijman)
* Fixed size of available flash for mega2560 boards (Leonardo Milani, Arnav Gupta)
* sam: removed useless empty digitalPinToTimer(..) macro stub (Bill Perry)


arrggghh

I didnt realize the beta was changing so much between relatively late releases.


Please use IDE 1.5.7 at the moment


Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 09:41 pm
Guys,

In case this helps initially getting stuff working, I used STM's own flashloader to start with, though its pain to have to use it, as you need to run the IDE in verbose mode to get the location of the bin file that gets built, and also the last slash in this path is around the wrong way, so you have to paste to a text editor, change it and then paste the updated path into the file dialog in STM's program.

But its good for testing the initial connections

See Details, I just PM'ed to @mcnobby


-----------------------------------------------------------------------------------------------

Hi,

Just thought I'd PM this to you

STM have their own flash loader PC windows program, you can use it to test if you are in bootloader mode


http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/demo_and_example/stsw-mcu005.zip

install it

run it

select the comm port   (I left the other settings the same i.e 11500 Even parity echo disabled timeout 10 (you could reduce the timeout to 2 secs)

Press Next

You should get a green traffic light

Press next

It should tell you the chip details etc

Press Next

You should be able to both upload and download (though I find their nomenclature to be backwards)

Download to device, is the command to send data to the device (I'd normally call this Upload to device) but never mind.

So Upload from device   means Download from device to the PC, ie if you want to retrieve whats already in the board, namely the maple bootloader, you could.
But not really necessary unless you want to confirm that the board does talk to the USB.
The binary of the maple bootloader is in GitHub if you really need it

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 09:57 pm
@all

I just installed 1.5.8 (alongside 1.0 and 1.5.7) - as the main Arduino installation

And its working OK for me

Well Blink works, and I2CScanner works


However at the moment, even with my experimental version, I get an immediate error as soon as I attempt to use SPI i.e I can #include <SPI.h>

But as soon as I try

SPI.begin()

in the code, it tells me SPI is not declared in this scope.

So somehow SPI is not actually getting included.

:-(

I'll need to try to figure out how the IDE works out its include paths, because SPI is in the same location as Wire

i.e hardware\Arduino_STM32\STM32F1XX\libraries\SPI  for SPI
and

hardware\Arduino_STM32\STM32F1XX\libraries\Wire for Wire

and including Wire.h works OK .



Title: Due vs STM32F103 @ 72Mhz speed tests
Post by: rogerClark on Nov 15, 2014, 10:11 pm
@All

Just thought I'd let you know the speed test results for things like digital write

I just ran this on the Due

Code: [Select]
void setup() {
  pinMode(2, OUTPUT);
  while (2)
  {
    digitalWrite(2, HIGH);
    digitalWrite(2, LOW);

  }
}
void loop() {}


And my scope is showing 202Khz square wave

Ran basically same test on the STM32


Code: [Select]
void setup() {
  pinMode(PC14, OUTPUT);
  while (1)
  {
    digitalWrite(PC14, HIGH);
    digitalWrite(PC14, LOW);

  }
}
void loop() {}


And I'm seeing 900khz !


However a suspect a lot of this is to do with the coding of the digitalWrite

Its fairly convoluted in the SM32, so must be even more complex on the Due, otherwise it wouldnt be over 4 times slower.


Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 15, 2014, 11:21 pm
Guys

I'm still drawing a blank on SPI, so I've tried posting a question to the Programming section

Very strange things happen with SPI, in the build process

Firstly, there is this strange message at the start of the build

Quote
Using library SPI in folder: C:\Users\rclark\Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\libraries\SPI (legacy)
which rings alarm bells with me, because why the IDE would bother to tell me this unless its doing something dodgy.


It only does this if I include SPI.h, which makes me think that the IDE is doing something very odd with any builds that include SPI.

I've also posted an Issue to the Arduino IDE issues list on GitHub

Hopefully some clever person will enlighten me about the SPI build process and what hoops you have to jump through in order to get the IDE to accept SPI.begin

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 16, 2014, 10:10 am
Guys,

I'm still waiting for any useful responses to my SPI questions, but I came across some stuff that I think @mrbrunette found about the new library API for 1.5 and above

I have posted to the core Arduino dev group on Google Groups and if i get chance I'll try converting my files to use the new system to see if it gets around this current impasse with SPI

Cheers

Roger

Edit.

Nope. Its not the new API structure thats causing the issue.

However I think I've made some progress (finally) with this

Its a bit of hack really, but if I add this line into wirish.h

#include <../../libraries/SPI/src/SPI.h>

then SPI.h gets included and my empty SPI cpp with just stub functions seems to get compiled in.

However it the moment it doesn't do anything !




But I'm afraid its a work day tomorrow, so I'll have to call it a day and perhaps get some time tomorrow to look at putting the calls into SPI.cpp to use the Hardware SPI

Just an aside, I checked to see how SPI.h gets included for the SAM core and its in a similar way

What the SAM core seems to do is that  Arduino.h includes Chip.h which includes SPI.h

Anyway.... There is a light at the end of the tunnel now and I don't think its an oncoming train ;-)


Have a good Sunday (As I know its only just starting for most of you)


Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 16, 2014, 11:44 am
OK, so many thanks to Roger for PM assistance (although I had missed it when he posted it on this page !!)

I tried the ST flash downloader demonstration app

http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/demo_and_example/stsw-mcu005.zip (http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/demo_and_example/stsw-mcu005.zip)

Managed to get comms between my PC and my STM through my USB->serial
I got about 90% failed connects but I dont think that is my problem generally as I was getting the same error from the IDE even when I didnt have my USB dingle plugged in !

Now I know my STM32 board is alive and communicatring I shall carry on..
Downloading a fresh IDE 1.5.7, fresh STM32 files, fresh socks and a fresh cuppa tea !
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 16, 2014, 12:18 pm
@mcnobby

No worries

The stm utility almost seems to time out somehow.

I found it best to keep resetting the board just before I ran the stm util.

I have occasional problems with the exe I use for the IDE, but I can't quite work out what causes it.
I thought it could be loose connections, but sometimes I can upload time after time without any problem, but other times I get failure after failure.

If it fails more than twice in a row, I now try unplugging and reconnecting the USB

But I have also noticed that the IDE seems to confuse the uploader, so I also sometimes quit the idenand restart it, when its really playing up.

On the whole however its generally reliable enough to use, once you get it working at least once, I.e you know it can work.

In the longer term I guess we need to work out what makes it intermittent

Anyway, good luck with it today

Cheers

Roger
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 16, 2014, 02:08 pm
I found it best to keep resetting the board just before I ran the stm util.
I have been doing that, maybe my USB->Serial is dodgy, always worked before though
Quote
But I have also noticed that the IDE seems to confuse the uploader
I wonder if thats what I am seeing, my IDE seems to know the uploader is there, but doesnt seem to boot it into action and reports back 'no error'

Do I need to connect a reset to the USBSerial ? I havent mainly cos I am manually resetting etc

Quote
Anyway, good luck with it today
... and a large hammer !! ;) Cheers Roger
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 16, 2014, 08:18 pm
Re connecting reset to the USB to serial.

No. At the moment there is no way to do this with the PC exe that I'm using as I can't get the source to compile, so I can't modify it in order to send a reset.

I will need to stick that on my list ;-)


You need to manually reset before each upload at the moment I'm afraid

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 16, 2014, 09:22 pm
PROGRESS AT LAST !!

Compiled at tried to upload using IDE in verbose mode, failed upload but copy and pasted bin file location
loaded STM32 program utility, and set STM32 board to programming mode
Made connection using STM32 program utility and advanced to upload (download) page

COULDNT paste file location into fie name box, but by pressing "..." opens up a dialog box, I just pasted the file location there, NOT FORGETTING to adjust forward slash/ backslash error (see below)
Code: [Select]

FAIL: C:\Users\Bob\AppData\Local\Temp\build3263726092171588630.tmp/sketch_nov16a.cpp.bin
PASS: C:\Users\Bob\AppData\Local\Temp\build3263726092171588630.tmp\sketch_nov16a.cpp.bin


and BOOM, it uploads

Still would love to have this direct from the IDE, and I still havent figured out why STM32flash doesnt link from my IDE yet...

... BUT, progress is progress :) Happy Sunday :)
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 16, 2014, 09:54 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)


Interesting - 2me

I guess I have known that Arduino GUI is a loose compiler and that the linker is the smart piece of code.  I remembered from some past nightmare that GNU C/CC leaves file information in the .o file.  So, I thought I would see what could be gleamed from such a search.  I used Microsoft Win Find.exe to peer into the compiled file for strings.

I ran 2 tests: one was with the Maple IDE virgin - I loaded BareMinimum and set the board to Mini Rev2 to Flash.  After the compile, I navigated to the %temp% directory and used the output from the GUI to find the correct folder.  Then I dropped into a command window and used Find "Maple" against *.o and copied the results into a text file.

For the second test, I used rogerClark's Github expanded under the \Arduino\hardware and used Arduino GUI 1.5.7, selecting BareMinimum and the same board type as before.

On my workstation, Rogers work is under D:\Documents\Arduino\hardware\STM32\STM32F1XX\
So, after I do the compile in ArduinoGUI, I go to the temp directory and open a command prompt.  Then I issue the command find "STM32" *.o >Find_STM32
Next, I type notepad.exe Find_stm32
The results shown indicate all the lines in the file with core or library routines coming from the STM32 directory.

Were I to type find "Arduino157" *.o >Find_STM32 then I would only see the file names checked with no expansion of the interior of the file, that is, a null is returned.
Here is a snippet of what a null response returns:
Code: [Select]
>find "Arduino157" *.o

---------- ADC.C.O
---------- ADC_F1.C.O
---------- BKP_F1.C.O
---------- BLINKONBOARDLED.CPP.O
---------- BOARD.CPP.O
---------- BOARDS.CPP.O
---------- BOARDS_SETUP.CPP.O
---------- CXXABI-COMPAT.CPP.O
---------- DAC.C.O
---------- DMA.C.O
---------- DMA_F1.C.O
---------- DTOSTRF.C.O
---------- EXC.S.O


Why is this interesting:  Because I now know where the core and libraries modules are originating!  If a sneaky file from \Program Files (x86)\Arduino157\ gets pulled into the mix, I should be able to make that determination, hopefully form the Find output.

Ray


In the files attached, the MapleIDE is the old, original MapleIDE from Leaflabs and installs into the C:\Program Files (x86)\ directory

The file named Arduino157IDE is from Roger Clark's rework of the BobC previous work effort
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 16, 2014, 10:05 pm
@mcnobby

It sounds like you already did this

But to get the location of the bin file, I turn on verbose and look at the final .bin file bit of text and cut and paste it

But as you've noticed there is a bug in the IDE and the last slash on the path is the wrong way around

which means you can't cut and paste this into the STM32 loader program's input box

So what I normally do is paste into at address bar of a folder window e.g. double click on my documents
then paste the text from the IDE into the address bit at the top

This changes the slash at the end to the right way around

Then I copy the address

goto stm32 uploader

paste it into the open file dialog

select the bin file

then upload

I've no idea however why the STM32 flash uploader is not working

You could try installing python and use the python one instead.

I posted details on how to use the python loader a while back, but I know this thread is huge now, so it could be hard to find.

I think in the current github version I put the python file in there

and if you look in serial_upload.bat in tools/win  you will see its remmed out

rem C:\Python27\python.exe stm32loader.py -e -w -p %1 -g -b 230400  %str%



so if you rem the line above and then un-rem that one

and have python installed e.g in the same location

it does work (at least it did for me ;-)

You may need to change the path to python if its not python27 in that location


But its fantastic news you have it working !!!!
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 16, 2014, 10:12 pm
Ray

Thats interesting.

I've been looking at the pre-compiler output using -dM -E or just   -E switches but its very verbose, so that other way to look at what is included is interesting.


BTW. I was hoping to look at SPI this morning, for an hour before work, but instead I've made a youtube video tutorial on the basics of getting this working.

But its taken ages, as I had to re-do it at least 3 times, and also the screen capture thing (Microsoft Expression - free version) has issues with menus getting left on the screen, which means I keep need to close and restart the IDE


Re: SPI

I think there is some sort of hack going on with the existing build process for the SAM core (not sure about the AVR), where SPI.h gets included once via Arduino.h

Strangely however you still need to include it in the sketch, so there is obviously something dodgy with the way the Arduino build process and various work-arounds under the hood that they don't tell you about

I'm not going to have time to look at SPI until this evening i.e around 12 hours from now, as its 8:10am here and I need to get some fresh air and then get on with work ;-(




Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 16, 2014, 10:23 pm
Ray,

If you plan on working on the SPI stuff today, I can upload the latest files to git hub as I think they are stable

But you'd need to work out how to put the hardware SPI code into the empty stub functions I have in the SPI.cpp and SPI.h

And unless you have a scope etc, it could be hard to work outs whats going on

But let me know if you feel like doing some hard core programming ;-)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 16, 2014, 10:42 pm
@Roger
Rgarding the Python loader, I looked at the bat file and saw the remmed out line a few days ago but decided not to pheck with it as I know nothin about python, but now I shall give it a go, I have nothing to lose

Also, I see there is some lines in the bat file (or somewhere) that corrects the backslash ? am I right ?

It is good to get it working, and I want to do some speed testing as I see you have already started, cos I need this little beasty to slide nicely off a shovel just like sh..... ;)

Its been a good day, thank you :)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 16, 2014, 11:28 pm
mcnobby



yes. That weird bit of code is to correct for the bug in the IDE which puts the wrong direction of slash at the end.

I just found some code on the web that does a string search and replace in a .bat file  and changed it to replace forward slash with back slash



Its odd that the STM32flash prog doesnt work in its own write, and that you have to use the STM one.

You could try running the STM32Flash exe in the tools/win folder manually

It could be a baud rate issue.

remove the -b 203400 bit and it defaults back to slower speed.

The docs on the exe say its 115200, but I have a feeling this is wrong and that its only 57600 baud, but I've not actually measured it

I found with my USB to serial (which comes up as "Pacific ... something or other" in Windows device manager), it works fine at that high baud rate, but it could be that yours don't work that fast

In fact thats definately one thing to try

I'll pm you in case you don't see this

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 16, 2014, 11:47 pm
Cheers, I shall try that tomorrow as its late here 10:45pm - you sound quite hopeful

I know I have been a pain, but problems often create solutions, and I am sure I wont be the only one to have this kind of problem, then if we know what worked.. BOOM... sorted :)

Roger, did you ever find out if the STM32 was actually faster than then UNO ?
I havent read anywhere if anyone has used the #defines to ramp the speed up yet

Regards Bob
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 17, 2014, 12:10 am
@mcnobby

The initial speed test I did was a complete red herring.

The speed came out the same as a Uno, because the sketch had delays in it

I did another test against the Due and for the thing I tested the STM32 was 50% slower than the Due :-(

However I also did a simple digital write on/ off test and the STM32 was 5 x faster than the Due

Its probably not been done before unless someone has written something to compare the speed of a Due to a Uno, and really the speed should be a bit slower than a Due as the Due has a slighly higher clock and possibly the Due has floating point hardware (I'd need to check)

In my floating point maths test that would explain why the Due was 50% faster.

But doing maths on both the Uno and the Due the code would need to be written carefully as the STM32 gcc uses real double point FP where as on AVR the double type is typedefed to float i.e single precision.  So if the type is not specified in some operations, it STM32 could be doing stuff in double precision and the Uno in single precision

Anyway, I'll post to the Due forum


Edit.

Just found this

http://playground.arduino.cc/Main/ShowInfo

Which has Speed tests

I think Ray ran this already, I wonder if he ran the speed tests and how they stack up







Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 17, 2014, 12:21 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Ray,

If you plan on working on the SPI stuff today, I can upload the latest files to git hub as I think they are stable But you'd need to work out how to put the hardware SPI code into the empty stub functions I have in the SPI.cpp and SPI.h  And unless you have a scope etc, it could be hard to work outs whats going on
But let me know if you feel like doing some hard core programming ;-)
My intent was to push the STM stuff aside and work with CF on the 1284 as thee weekend did not provide the opportunity said another way, the wife did not allow much time for play.  I had more free time before I retired.

But, go ahead and uodate github OR your Zip if you like.

Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 17, 2014, 12:37 am
Hi Ray

Its OK.

I better check its not got too much junk in it

I'll upload this evening (my time)


PS.

I just tried to compile the ShowInfo  sketch from the Playground   http://playground.arduino.cc/Main/ShowInfo

But on 1.5.8 it won't compile at all, for any platforms. Even the Uno compile fails.


I've seen this quite a lot actually.  I guess it should work with 1.0 IDE but often I find stuff on the website doesnt seem to work

I'll need to do a cut down version that just does some speed tests and not stuff which seems to be playform dependant
Title: My Maple Mini's have arrived
Post by: rogerClark on Nov 17, 2014, 06:16 am
Guys,

My Maple mini clones arrived today from an eBay seller in China

They have BTE14-7 and Bait written on the silk screen, so it looks like they are the same as other people have received.

The pin headers are not soldered on, so I need to do that before I can test at all.

Well I guess I could mess around with the Maple Drivers in unsigned mode for a while, as that just requires USB

Title: YouTube Tutorial ;-)
Post by: rogerClark on Nov 17, 2014, 08:11 am
Hi Guys,

This wont tell you anything you don't already know, but for anyone just starting out on this journey it may help.

I've made a tutorial video that covers the installation of the files and shows the upload process and the I2CScanner working

See  https://www.youtube.com/watch?v=-zwGnytGT8M (https://www.youtube.com/watch?v=-zwGnytGT8Mhttp://)

I guess you all get to hear my voice now. ;-)

Cheers

Roger




Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 17, 2014, 08:59 am
This wont tell you anything you don't already know, but for anyone just starting out on this journey it may help.
Really informative Video Roger, thank you, I think I may have just seen something while watching it..
Your uploader gets to "Using Parser : Raw BINARY" which I believe is a comment that comes from the flash uploader

Your upload continues where mine stops dead

I have a feeling it maybe something to do with the / \ correction..
I am running windows 7, perhaps there is something about that that doesnt parse your bit of code to convert the backslash, as yet I havent tried the remming as I have just got up, but I will try it later

Its just a thought :)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 17, 2014, 11:41 am
@mcnobby

OK.

Now I have a Maple board, I can see the same problems that you are experiencing.

There appears to be something that the Maple hardware is doing that is interfering with the boot sequence of pressing and holding down the button and then resetting the board.

I'll need to look at the circuit to figure out whats happening, but in the mean time I have a not that easy work around

The way to put it into bootloader mode seems to be

Disconnect the power (you can do this by pulling the whole USB to serial out if this is powering the board)
Then Press and hold in both buttons (and keep them held in !!)

Plug in the USB to power up the board.

Release the reset button , while still keeping the other button held in for a moment, 1/10 a sec would be enough, just release the reset first

Now if you run STM's flash program, it seems to reliably connect.

Do what I'd recommend you do for the moment is, run Windows 7 in that special mode that allows unsigned drivers and use it via USB.

I have tested this and it works OK and its what Ray uses.

i.e reboot windows 7, press F8 as it starts to boot and select the option that disables the device signing requirement


But.. If you have uploaded a sketch directly, the Maple bootloader will have been overwritten

So unzip the attached file and use the STM flash program to flash the maple mini bootloader bin file back onto your maple.

It after reset it will have a couple of USB devices,

The drivers are part of my files in driver/win

I will now need to look at the circuit to figure out why its not reliable without removing and reinstating the power.





Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 17, 2014, 11:59 am
@mcnobby

Mystery solved

The reason this is intermittent is that line Boot1 is floating, you need to pull it low.

Whats happening is the boot mode is determined my lines Boot0 and Boot1

Boot0 is connected to both the "button" and also to PB8 on the chip its self.
Boot1 is run out to pin Pin 2, and is also labeled on the board as Boot1

You need to pull this low permanently, as a test I just connected a wire directly from Boot1 to GND, but ideally you need to do it via a 1k resistor in case your program decides to drive PB8 as this could damage the chip (but probably only PB8)

As soon as I did this, the loading is ultra reliable

So either you can use the Maple way, which works and uploads really fast, but you need to boot into that special mode each time you start windows, or you can use the USB to serial adaptor

I'm not sure how everyone else feels, but I may change the Serial name assignment for Maple boards so that USBSerial just gets called Serial

This is line with what the Mega does, ie its hardware Serial1 goes out via the FDTI chip and gets called Serial,  and its hardware Serial2 gets called Serial1


This would mean that anyone using the DFU mode would not need to do a search and replace

I'd just add a function for SerialUSB.begin() that does nothing ;-)



@mrbrunette  - as you use the Maple drivers etc, would this serial remapping be acceptable to you

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 17, 2014, 03:27 pm
You need to pull this low permanently, as a test I just connected a wire directly from Boot1 to GND, but ideally you need to do it via a 1k resistor in case your program decides to drive PB8 as this could damage the chip (but probably only PB8)
if you refer to a board with c8 or cb chip i think you might be confusing boot1 with boot0. boot1 does need to be grounded but no resistor required because theres no way to use it as io (b2 not b8) and still flash the chip. boot0 should have a resistor to ground but not to avoid conflict with io (again not b8 which is a different pin). rather its to allow the user program to run stand alone if open and to flash if shorted to vcc.

btw contrary to popular opinion shorting a pin will never cause damage. not even on an avr which has several times more drive capability.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 17, 2014, 05:39 pm
Mystery solved
The reason this is intermittent is that line Boot1 is floating, you need to pull it low.
I had that link on for quite a while now, even through my last testing
Thanks for all the new Info Roger, many new things to try now, but I am glad you got to experience a bit of what I was struggling with

I am hoping to fix the uploader in the bat file later and maybe try a few other things

Thanks for the maple file, I had realised I had overwritten the original bootloader when all the mad flashing stopped and never returned !!

So are you saying I CANT just upload direct from the IDE unless the maple bootloader is resident in the chip ?

:) <- smiling
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 17, 2014, 05:55 pm
I have just been reading the ST flash uploader demo PDF
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00171488.pdf (http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00171488.pdf)
Section 3 describes the command line usage

I am wondering if the IDE could kick the flash uploader program with all the right switches and filenames

I will carry on reading..........
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 17, 2014, 06:46 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

I'm not sure how everyone else feels, but I may change the Serial name assignment for Maple boards so that USBSerial just gets called Serial
This is line with what the Mega does, ie its hardware Serial1 goes out via the FDTI chip and gets called Serial,  and its hardware Serial2 gets called Serial1
This would mean that anyone using the DFU mode would not need to do a search and replace
I'd just add a function for SerialUSB.begin() that does nothing ;-)

@mrbrunette  - as you use the Maple drivers etc, would this serial remapping be acceptable to you
So the serial nomenclature would follow:
Quote
The Arduino Due has three additional 3.3V TTL serial ports: Serial1 on pins 19 (RX) and 18 (TX); Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). Pins 0 and 1 are also connected to the corresponding pins of the ATmega16U2 USB-to-TTL Serial chip, which is connected to the USB debug port. Additionally, there is a native USB-serial port on the SAM3X chip, SerialUSB'.

The Arduino Leonardo board uses Serial1 to communicate via TTL (5V) serial on pins 0 (RX) and 1 (TX). Serial is reserved for USB CDC communication.
ALSO
"Legacy" appears to be a feature :smiley-twist:  of GUI 1.5.x as I went back and compiled a few older sketches under th new GUI.  From what I can tell, the GUI adds this tag whenever library code is pulled from locations that are "global" ; which is to say, "Not encapsulated" in the \Arduino\hardware area:
Code: [Select]
Using library SPI in folder: C:\Program Files (x86)\arduino_157\hardware\arduino\avr\libraries\SPI (legacy)
Using library Adafruit_GFX in folder: D:\Documents\Arduino\libraries\Adafruit_GFX (legacy)
Using library Adafruit_ILI9340 in folder: D:\Documents\Arduino\libraries\Adafruit_ILI9340 (legacy)
Using library SoftwareSerial in folder: C:\Program Files (x86)\arduino_157\hardware\arduino\avr\libraries\SoftwareSerial (legacy)
Using library Streaming in folder: D:\Documents\Arduino\libraries\Streaming (legacy)


Speaking of library search, I am having a problem instructing the sketch to pull code from the path
\Arduino\hardware\STM32\STM32F1XX\libraries
The core files and headers seem to pull OK, but libraries are problematic.  Also, there seems to be an issue with 1.5.7 where .h and .cpp files located in the sketch directory are not pulled correctly... as was the case with 1.0.6.  I'm still trying to figure this out, so do not hold me what I think I am seeing as it could be smoke n mirrors.

Ray
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 17, 2014, 07:15 pm
I am wondering if the IDE could kick the flash uploader program with all the right switches and filenames
yes. as i mentioned to you in post #417 that is one of the better utilities to flash stm32. it has the great advantage of not only being able to automatically reset via serial handshake pin but allow programming without having to press any buttons.

ive now managed to successfully make use of 4 different flash utilities with rogers ide:

1. default stm32flash.exe
2. python script
3. stmflashloader.exe (above)
4. stvp_cmdline.exe

they all do an excellent job but #3 is my favorite for reasons mentioned. the blinker and i2c seem to be running fine now and im looking forward to some spi testing next.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 17, 2014, 08:12 pm
@mcnobby.

No. You can upload from the IDE even if there is no maple bootloader, if you have USB to serial

The maple bootloader is only necessary if you want to upload using the micro USB connection on the board.


Did you pull boot1 to ground and still have issues even with stm s own flash loader windows program??
This seems very odd. As soon as I pulled boot1 to GND, everything started to work fine for me.

If the stm program works and the IDE doesn't, try modifying the serial_upload.bat remove the -b 203400 as this will revert it to slower serial transfers, which I think are 115200 or 57600

Actually, if you can get stm s own program working, try changing the baud rate and see the fastest that is reliable. I think it goes up to 250,000 or there abouts.

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 17, 2014, 08:23 pm
@mrbrunette (Ray)

I agree there is something very odd going on with the way the IDE handles the library folder.
Which I still don't understand.

With SPI, if I added #include <SPI.h> in the sketch, and looked at the verbose compile, I could see it it compiling SPI.cpp in in the stm32f1xx libraries folder

But as soon as I tried to add the line SPI.begin() I got an immediate error.

The only way around this at the moment is to add the include for the new library, in this case the SPI to wirish.h,  using ../../ in the include path.

I even changed the SPI lib to the new structure where the source files are in a folder named src inside the SPI folders, and added the properties file, but it still required me to put the include into wirish.h


Strangely the AVR boards don't need to include SPI in arduino.h but SAM does (indirectly)

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 17, 2014, 08:35 pm
Guys,

Unless anyone has any objections, I'm going to rename SerialUSB to Serial, and add a begin() method that takes one argument so that the API for the maple boards using the maple bootloader and on board usb, is the same as the normal Arduino API.

I.e currently the maple bootloader operation IDE doesn't have something called "Serial"

Title: Th need for speed ;-)
Post by: rogerClark on Nov 17, 2014, 08:38 pm
I found this on how to improve digital read and write speed

http://www.codeproject.com/Articles/732646/Fast-digital-I-O-for-Arduino

I may try it, and if its faster than the current code, I will probably use it.

And as we have free reign to do what we like with core functionality, can anyone let me know if they have any other nigglies with the way Arduino works, that core be improved for STM32

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 17, 2014, 09:13 pm
JTAG / STLINK / SWD

Apart from the zillions of things I have still yet to try...
my ST-LINK (the tiny USB one) arrived today, so I couldnt resist having a go...

Well, the software installed fine and the drivers...
had a good google around and found I had to connect the following

STLINK SWDIO  -> STM32 board PA13
STLINK SWCLK -> STM32 boards PA14
power 5v -> vcc
gnd -> gnd

I also grounded BOOT1 (Roger)

and guess what ? the software app kept teling me it wouldnt connect !! ha ha (seems the theme for me !)

anyway I did abit more routing around, concerned that the stlink (or STink as I like to call him) would only work in debug mode rather than programming. I need to research more but I think I read about jumpers on the Nucleo boards that had to be set/unset for programming

More to do

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 17, 2014, 09:17 pm
I found this on how to improve digital read and write speed
http://www.codeproject.com/Articles/732646/Fast-digital-I-O-for-Arduino
I rarely use digitalWrite these days, since I found PORT |=  bitmask; and PORT &=  ~bitmask; I havent looked back :)
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 17, 2014, 10:09 pm
anyway I did abit more routing around, concerned that the stlink (or STink as I like to call him) would only work in debug mode rather than programming. I need to research more but I think I read about jumpers on the Nucleo boards that had to be set/unset for programming

More to do
boot1/boot0 must be in run mode not flash mode for the swd to work. if the link that westfw posted at the beginning of this thread was followed up a lot of tail chasing could have been avoided. it is a very education site for this chip and many questions and hours of work could have been avoided. at least that was true in my case and ive only been working at it for couple days.

i understand everybody has their own way of doing things so for now ill just sit back and patiently wait for progress. im very grateful to paulrb for starting this thread and initiating the whole process and do appreciate all the hard work people are putting into it.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 17, 2014, 10:31 pm
@john1993

Just found that link

http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf (http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf)

Maple mini pulls boot0 to GND via 10k unless the "Button" is pressed in which case its pulled up to High by 1k.

Boot1 on the the maple is left floating, which I think is a bit of a design error, they'd have been better off nominally pulling it low via 10k or perhaps something higher e.g. 47k


@mcnobby

My STLink clone still hasn't turned up. It looks like a whole batch of stuff got lost somewhere as I ordered it getting on for 8 weeks ago with some other stuff from different eBay suppliers in China, and none of it has arrived.

Stuff I ordered since then e.g.. the Maple Mini's has arrived, which is the strange thing.

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 17, 2014, 10:50 pm
@mcnobby

Quote
I have just been reading the ST flash uploader demo PDF
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00171488.pdf
Section 3 describes the command line usage

I am wondering if the IDE could kick the flash uploader program with all the right switches and filenames

I will carry on reading..........
I noticed that STM's flashloader had a command line interface, but as I can't package as part of my code, because of the license conditions, I didn't think it worth looking into, especially as STMFlash.exe works fine as does the Python uploader, both of which are open source.


Interestingly see this posting thread on ST's user forum

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FFlash%20Loader%20Demonstrator%20v2.1.0%20RTSDTR%20control%20issue&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=12533


Basically someone is trying to use the hardware lines on his serial device to trigger the reboot into the correct mode for upload

Quote
On my hardware I've connected the RS232 RTS and DTR signals to NRST and BOOT0
I guess this is one way to do it, but I don't know of many USB to Serial adaptors that have the full compliment of control lines

The only one I can find is $28 from a local supplier.


Really the best way to do this is to have a board with 2 x STM32F103's on it, as they are literally dirt cheap, and use one just to provide a serial interface for programming, which uses a signed driver e.g. the Arduino drivers must be signed for the Leonardo ??

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 17, 2014, 10:59 pm
@john1993
Boot1 on the the maple is left floating, which I think is a bit of a design error
i agree. its floating on my maple boards too which at best results in intermittent operation. i have two other stm32 demo boards now where that pin is hard ground as it should be. boot0 has a proper 10k pull down on all these.

i also notice maple shorted boot0 to b8 as you mentioned earlier which makes no sense at all. maybe as a security dongle trick to force captive market. where is their $40 product now? thats right...

they screwed up a lot of the software too as you have discovered. hopefully the great minds here will fix all those kind of problems and pick up where they left off.

btw i again highly recommend following that eevblog link westfw posted earlier. it discussed all these issues in great detail and others not brought up yet. also leads to one showing how to build these for one dollar including shipping and details on how to use the serial dtr pin so no buttons need pushing.
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 17, 2014, 11:06 pm
I guess this is one way to do it, but I don't know of many USB to Serial adaptors that have the full compliment of control lines

The only one I can find is $28 from a local supplier.
http://www.ebay.com/itm/USB-2-0-to-UART-TTL-6PIN-Connector-Module-Serial-Converter-CP2012-TN2F-/291224501288?pt=LH_DefaultDomain_0&hash=item43ce553c28

they are available for less than a dollar some places. ive been using that exact betemcu (baite is a pcb house) unit for years with arduino and now works perfect for stm32.

be aware as mentioned in the arduino tutorials rts does not work under windows due to os issues. however dtr works fine and is used in the eevblog thread to eliminate need to push buttons.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 17, 2014, 11:18 pm
@john1993

Quote
i also notice maple shorted boot0 to b8 as you mentioned earlier which makes no sense at all. maybe as a security dongle trick to force captive market. where is their $40 product now? thats right...
I saw that as well.

I'm not quite sure what they had in mind.

I can see that they did do loads and loads of work at the time, as there is a lot of code.
Perhaps at the time $40 was an OK price if it had worked well and been totally compatible with SPI and I2C rather than them not implementing quite the same API for serveral parts of the hardware


Anyway, I'll look for that link to the EEV blog again.

BTW. I'm running my Maple mini using USB by disabling device driver signing, but even then its a bit flakey at times, and the comm port doesn't always show up :-(



Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 17, 2014, 11:45 pm
Re: Serial vs SerialUSB on using the Maple mini bootloader

I tried changing the SerialIUSB stuff to Serial, but it just crashed when I ran it

At the moment I'm not sure why this is, I'll have to look at it again this evening
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 18, 2014, 09:00 am
Some more if my eBay purchases arrived today, but still no sign of the JTAG (STLink clone)

I did however get 2 more STM32F103 boards, a C8 on a different form factor board, and also a RCT6 which has more ram and rom than the ones on the Maple mini

However I have not been able to upload to either (but I only had a few mins at lunchtime to try uploading)

I'll try again later
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 18, 2014, 09:14 am
I ordered another board, and one of those minimal development boards (the one with all the headers already in place)

I also have some LQFP 48 CBT6 chips coming, they are very cheap ! and some breakout PCBs - I like to play even though this one is a bit of a bugger !!
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 18, 2014, 10:57 am
@mcnobby

Well I got this one working

http://www.ebay.com/itm/ARM-Cortex-M3-STM32F103C8T6-STM32-Core-Board-Minimum-System-Development-Board-/301247607101 (http://www.ebay.com/itm/ARM-Cortex-M3-STM32F103C8T6-STM32-Core-Board-Minimum-System-Development-Board-/301247607101)

(http://i.ebayimg.com/00/s/NjAwWDYwMA==/z/yFIAAOSwX6VTyOm2/$_12.JPG)

However it didnt want to work with the IDE using STM32Flash

I got it working with python

Initially it didnt even worth in python, but I tracked down the error being that the device type length was more than 2 byes. 

But this appears to be OK, as it looks like the additional 2 bytes are a sub - version of the device

Python expects

0641

But it got

06410041

The device is a  Medium_Density PL  I'm not sure what that means, I think it may be a lower spec than the other STM32's I have



The python script didnt know what a 0641 was, but it now still uploads and it works OK.

I've attached an updated python version, which I will check into GitHub soon

You could try using this python script as it would explain why the STM uploader worked for you and not STM32Flash.exe

There may be a newer STM32Flash source code available, but so far I've been unable to compile it on windows

Well someone must have managed, as there exe versions out there but a lot of them are old.



Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 18, 2014, 11:24 am
Success on my other STM32F103 board

After some research I tracked down where it came from (ie the eBay seller wasnt the manufacturer )

Its this board

http://item.taobao.com/item.htm?spm=a1z10.3.w4002-4286024464.24.AEgEzv&id=36064371414 (http://item.taobao.com/item.htm?spm=a1z10.3.w4002-4286024464.24.AEgEzv&id=36064371414)

(http://gd3.alicdn.com/imgextra/i3/69708445/T2GBFuX4VXXXXXXXXX_!!69708445.jpg)

STM32Flash reads back

Version      : 0x22
Option 1     : 0x00
Option 2     : 0x00
Device ID    : 0x0414 (High-density)
RAM          : 64KiB  (512b reserved by bootloader)
Flash        : 512KiB (sector size: 2x2048)
Option RAM   : 15b
System RAM   : 2KiB


One thing I had to do was to solder a pin header for the 4 pins that read GND RX TX and 3.3 V because attaching it to PA9 and PA10 pins didnt seem to work, though this could be a red herring

I think the board came with firmware on it, but I stupidly didnt download it first, because I was initially having problems even getting STMs prog to talk to it

I'm not sure why it suddenly started to work, but it seems to be OK now

The board is covered in jump links, but I've no idea what they do, I'll have to look at the annotated photo again, to see if I can understand what its trying to say.

I'll also need to figure out which pin the onboard led is on

Anyway, at least its working !



Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 18, 2014, 12:03 pm
Edit.

I think stm32flash is wrong, its only 256k / 48k
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 18, 2014, 04:00 pm
Well I got this one working
I got it working with python
thats the one !
I shall take on board your tips

Quote
The device is a  Medium_Density PL  I'm not sure what that means, I think it may be a lower spec than the other STM32's I have
I was looking at this, I thought the Medium means 128k device, then I wondered if it was the package size, now I have no idea !!
 :)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 18, 2014, 04:04 pm
I tried to connect my stLink as I seaid before, I use the SWD using those connections (SWDIO, SWCLK, +v and gnd) and I got nothing

hang on... you connected your STLINK to rx/tx ?

Quote
One thing I had to do was to solder a pin header for the 4 pins that read GND RX TX and 3.3 V because attaching it to PA9 and PA10 pins didnt seem to work, though this could be a red herring
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 18, 2014, 08:06 pm
@mcnobby

I'm still using serial.

My STLink clone has not arrived yet :-(.  So I can't use JTAG.


I do find that serial can be somewhat flakey. Initially I could not get either board to communicate via serial even with STM s own uploader, I kept getting all sorts of messages about unsupported device, and a few other messages, and sometimes it just timed out.

With the STM uploader I've set the timeout to 1 second to save having to wait ages.

I'm beginning to wonder if I had power supply issues. I was powering via USB to the micro USB connector, and then just connecting RX and TX from the USB to serial.

But when I switched over to using power and ground and Rx and Tx from the USB to serial, things seemed to work.

I have noticed that on the PC I use for this stuff, that the USB voltage seems to be a bit less than 5v, but as these devices are 3.3v and have their own regulator I think, it should not be an issue.
But perhaps the regulators the use are not low dropout ones, and may be delivering less than 3.3v if the USB is 4.75v instead of 5v.


What I think I need to do now is to add new boards to the boards.txt for these new boards I have, because their flash and memory size is different.

I also need to get back to getting SPI to work, as these are somewhat of a distraction from the main game ;-)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 18, 2014, 08:16 pm
I'm beginning to wonder if I had power supply issues. I was powering via USB to the micro USB connector, and then just connecting RX and TX from the USB to serial.

But when I switched over to using power and ground and Rx and Tx from the USB to serial, things seemed to work.
I was only ever powering from the USB>Serial

... and I thought that Vcc on the mapleduino was 3.3v initially, the LED was a bit dull, then I realised about the regulator (on the back, I hadnt noticed, 0/10 for observation !!)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 18, 2014, 08:48 pm
@mcnobby


Whats the current status of your Maple mini boards?

Do they work occasionally on Serial or not at all

Have you tried booting Windows 7 into the special driver sig' not require mode (using F8 when windows starts to load ), so that you could try the official , though also slightly flakey, upload via the on board USB ?

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 18, 2014, 08:54 pm
@rC, they work occasionally, after many unplugs & resets on serial, I have tried the rC python remedy and no luck yet, I somehow feel like the uploader is rejecting the filename for some reason

I havent done the reboot-f8-knockout yet :)

Its a shame EVERYTHING seems so flakey... I never had any dodgy uploads with arduino ATMegas etc, on serial, SPI etc (unless it was an own goal of course)

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 18, 2014, 09:08 pm
on the Python uploader, I am getting a message at the end of the verbose...

Code: [Select]
Traceback (most recent call last):
  File "stm32loader.py", line 28, in <module>
    import serial
ImportError: No module named serial


I dont know what it means :()
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 18, 2014, 09:34 pm
umm

You cant have a full python installation :-(


See https://learn.adafruit.com/arduino-lesson-17-email-sending-movement-detector/installing-python-and-pyserial
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 18, 2014, 11:13 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
Its a shame EVERYTHING seems so flakey... I never had any dodgy uploads with arduino ATMegas etc, on serial, SPI etc (unless it was an own goal of course)
I just do not understand this!
I can utilize serial-USB and DFU from 1.0.5r2 or 1.5.8.  I do keep my USB adapters pruned which I have found in the past with Vista made a huge difference in success rate, but Win7 and Win8.1 seem to be a bit better, IMO.  Currently running 8.1 64-bit and 4G RAM on I3 dual-core Intel hardware... An old notebook just for Dev.

Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 19, 2014, 12:58 am
Hi Ray

I'm generally finding that uploading via USB to Serial is not 100% reliable.

I'm not sure why this is. It could be a bug in stm32flash.exe, as this is not the official STM uploader.

The python loader may be more stable, but I'm not using it most of the time because it doesn't seem to display upload progress until its complete, i.e the debug output looks like it needs to be flushed or something.

I think STM's own upload is more reliable, so if I get chance I'll work out what command line interface commands to send to it.

I agree that the Maple DFU stuff seems quite stable, and its very fast to upload. I'm not sure what speed it uses but it must be at least 500k baud.

With the 2 STM32 boards I got yesterday.  One of them (the bigger RCT8 one), will not upload via serial this morning, at all, even using STM's uploader :-(

So I think it may be a hardware fault. It was odd when I tried it yesterday. I couldnt initially get it to work, then suddenly at about 9pm it started to work.

The board has a battery on the back, and I'm wondering if it was flat and that keeping it plugged in for a while charged the battery and then it started to work

So I plugged it into USB this morning to see if I can leave it charging and perhaps it will start working.

This of course could be a complete red herring, but I've no idea what else could cause it to not work today when it worked fine yesterday and I left it plugged in.

Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 19, 2014, 02:22 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
'm generally finding that uploading via USB to Serial is not 100% reliable.
My experience is completely opposite.  It is 100% with the MapleIDE and maybe 90% with Arduino 1.5.8...
100% on second attempt.  This is as good or better than the ProMicro in my experience.

Ray
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 19, 2014, 02:42 am
Its a shame EVERYTHING seems so flakey... I never had any dodgy uploads with arduino ATMegas etc
thats strange, ive written dozens of programs over the last couple days using all four download methods on 3 different boards without a hint of intermittent failures. ive avoided the maple usb kludge because few got that to work reliably. the stm utility is my favorite because no need to hit any buttons. maybe time to start following advice from those who have similar good luck (ghetto education).

personally i had far more trouble with arduino caused by wrong handshake bit, wrong bootloader, wrong baud, wrong device code, etc etc. the list goes on as can be seen in this very forum. i wish avr had a built-in bootloader like stm. would have keep the "creative" types out of the equation.

in any case i hope you straighten out these bug speck issues so we can continue with serious testing of items that matter.
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 19, 2014, 07:47 am
Quote
uploading via USB to Serial is not 100% reliable.
My board has a somewhat flakey Reset Switch.  Normally, you can't tell, since there's no indication that you have entered the bootloader.  But when I was experimenting with ASM Blinky programs and such, some substantial fraction of the time, pushing RESET would not stop the experiment from running (ie the LED would keep blinking, even though it should have started bootloading.)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 19, 2014, 08:55 am
RE: Flakeduino - Perhaps this is why some of them are so cheap ? someone was talking about the number of layers on the board, and the baite ones only having 2 whereas the official ones having 4 - Although they are only running on an 8mhz xtal I just wonder how the cheapness/layers affect performance once the pll gets hold of the frequency

This could explain why we are having different levels of problems with very similar hardware :)
Title: Defective boards
Post by: rogerClark on Nov 19, 2014, 10:19 am
I have come to the conclusion that my STM32F103RCT board is defective

I measured the small switches connected to Boot0 and Boot1 and even when I pushed the switch across it didnt short circuit the switch, hence boot0 was not being pulled to 3.3V

So I soldered a wire across the switch, to keep it permanently in serial uploader mode, and it seems to work for a couple of uploads, then stopped working again

I suspect there is some other problem on the board, I may try using my reflow air gun on it in case there is a dry joint somewhere else e.g. between the processor and the PCB, but I the odds are not good

Actually my Maple mini is really reliable in DFU mode, its just a pain to have to boot windows into that special mode.

My generic STM32 board I originally got, is relatively reliable as well

I think its a combination of things, like westfw said, the reset switch may not work correctly some of the time, and also I think somehow the IDE leaves the stm32flash.exe in some sort of indeterminate state as quitting and re-opening the IDE often fixes things when it just won't upload.

Edit. I seem be experiencing the same thing mentioned my WestFW.
If I pressed the reset button, multiple times it seemed to work, so I thought that perhaps the reset button was broken, so I unsolded it and solder on another lager push button, but that didnt help and when I tested the button I removed, it seemed OK

I thought the other reason for problems is boot1 floating high, so I've soldered a wire from the boot1 switch to GND, and initially I thought this fixed it, but its now stopped working again :-(

There seems to be no reason for why it works some times and not others, perhaps these eBay sellers get reject's and pass them off as working versions


Title: Using STM's uploader
Post by: rogerClark on Nov 19, 2014, 11:17 am
Hi Guys,

After trying various combinations of things for the last hour or more, I've finally worked out how to use STM's own uploader  - command line interface exe with the IDE

The docs on the uploader (both windows IDE and CLI are here http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00171488.pdf (http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00171488.pdf) )


If anyone wants to try this method, open the serial_upload.bat in tools/win and rem out the line you are currently using, e.g. the stm32flash line (probably at the end of the file)

Then add these lines

Code: [Select]

rem ------------- use STM's own uploader
rem ---- Need to remove the COM bit from the comm port as the STM prog just wants the number
set commport=%1
set commportnum=%commport:COM=%
rem --- The maple board may nee the -i setting to be -i STM32_Med-density_128K
rem ---- 64 bit version
"%ProgramFiles(x86)%\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe"  -c --pn %commportnum% --br 230400  -i STM32_Med-density_64K -e --all -d --fn %str% --a 0x8000000 -r --a 0x8000000

rem  -- 32 bit version
rem "%ProgramFiles%\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe"  -c --pn %commportnum% --br 230400  -i STM32_Med-density_64K -e --all -d --fn %str% --a 0x8000000 -r --a 0x8000000




Note I'm running 64 bit windows 7, hence the path to the exe is programfiles(x86) but if you are running 32 bit windows 7 or 8, this will just be programfiles

in which case un'rem the last line and rem the one with the x86 in it.


Also note this was for a board which was STM32_Med-density_64K, if you are using a different board, you'd need to use STM's GUI version to retrieve this string first.
Actually its crazy that the CLI version seems to need this and the GUI one gets this from the chip its self, or perhaps looks it up from a list based on the device ID codes.

If you don't already have it, you need to download the program from STM site 

http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/demo_and_example/stsw-mcu005.zip (http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/demo_and_example/stsw-mcu005.zip)
and install it.





Anyway.

This does work ! Though I'm not sure if its any more reliable than the other methods.

Cheers

Roger
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 19, 2014, 01:05 pm
My board has a somewhat flakey Reset Switch.
a few pages back i mentioned that mine also misbehaved at first but banging on it real hard a few times fixed it. this is common. about 1 out of 50 or so of these cheap ebay tact(sic) switches suffer from infant oxide resistance syndrome. about 1 out of 500 can not be revived with reasonable coaxing so i just toss. the tiny rectangular ones worse than the 4mm and 6mm squares. still not bad considering they only cost a penny each.

many chinese products require this kind of rework. over there they understand and dont mind a little effort in the interest of economy. spoiled westerners do not understand and foolishly demand perfect function at bargain basement prices.
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 19, 2014, 01:46 pm
I've finally worked out how to use STM's own uploader  - command line interface exe with the IDE
very good. if you check out the "stm32 ghetto style" thread further it will lead to other useful hints like this. that danny fellow is very experienced and knowledgeable with lots of helpful information. this thread also leads to some other useful sites. for example the rcgroups link where another smart guy from germany uses these boards to build a flight controller that usually costs many times more.

i see that in a spinoff thread westfw has made huge contributions using the command line to compile and assemble for this very chip. theres an example there for auto reset and combining all that stuff into one simple line:


Quote
\stmflash\stmflashloader -c --pn 5 -Dtr --Hi
\stmflash\stmflashloader -c --pn 5 -i STM32_Med-density_64K -e --all -d --fn t.hex -r --a 0x8000000
ive been using this for some time now with that utility and it makes the maple just about as easy as avr-duino. actually easier because no caps or resistors needed. imo this stm32 setup has potential for not only great feature and performance advantage over the old arduino but cheaper and noob friendlier too.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 19, 2014, 09:03 pm
Thanks john1993

I've taken a quick look at that thread on the eevblog, and there is lots of information but 26 pages will take some time to read.

I don't think the issue on my 103RCT board is the switches, I replaced the reset push button and have permanently soldered wires to boot0 and boot1 at the moment and its still only connecting about 1 in 10 times.

Also even after I manage to upload using the GUI version of STMs loader, my simple Hello world number sketch which prints a number once a second via serial is nolonger running, when it was working fine 2 days ago.

I'm beginning to wonder if the issue is that the clock oscillator is not running, or whether there are power supply issues.
I'm running it on 3.3v from my USB to serial, which has worked fine elsewhere, but I will double check the voltage and perhaps try giving it 5v from USB as well.

But with surface mount chips like these its very hard to diagnose faults because I'd be hard pressed to get my scope probe onto the clock pins on the chip without shorting them to other pins.

Perhaps when and if my STLink clone ever turns up, I'd have more luck programming it that way.

I guess, I really need to just write off this board even though I paid $15 for it, and I'm not normally someone who gives up on things.


Edit.
I just can't let this rest..

But it seems if I power cycle the STM32F103RCT6 board, that most of the time the serial bootloader connects.
But even with my new push button for rest, it soldered to the board it hardly every connects

So I'll need to give up on this piece of junk for a while and do something more productive like getting SPI to work (Arduino API based SPI , as we know the HardwareSPI class works OK)

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 19, 2014, 09:43 pm
im glad to hear you are one who doesnt give up. i desperately want this to work and not being even close to the level of guys like you and the others on the adruino environment it will take me months or years. im starting in on it though.

as far as intermittent operation westfw had the same issue in the copycat thread and it turned out to be driver/hardware conflict with one of those garbage ftdi clones. the cheap cp2101 silabs type are far more reliable. specially the $1-$2 units i linked above. not one problem out of several hundred sent out so far.

as far as big threads after reading the first page to see if theres interest i then go to the end and work my way down to get the latest and avoid wild goose chases. as a kid they always did call me "backwards". lol.

edit: btw all my experience is with the 103c8 and 103cb chips. no 130rc but i dont think that matters. my favorite is the $7 ebay minimum demo board, first one in your product list blog.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 19, 2014, 11:29 pm
Thanks @john1993

I'll dig out that link for the USB to Serial

I have one that comes up in the drivers list as being my Prolific Tech that seems to work fairly well, but I can't see what chip is uses as it has some heat shrink plastic on it.


I just looked on my other one and it is a CP2102, but the confusing thing is the labels, it has RXC and TXC not RXD and TXD, and basically on that one, I have to connect RXD on the Serial USB to RX on the board (which I often get wrong as its contrary to what I normally expect)
It has RTS but not DTR but it doesnt have 3.3V out, it only has 5V out, hence another reason I tend not to use it.


Though if you think thats the most reliable, I'll switch to using it and see if uploads become more reliable
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 19, 2014, 11:35 pm
Guys,

I got an interesting reply from Paul (of Teenys fame) to my questions about SPI problems which were basically, would the SPI issues be resolved by using the new style library API ?

Quote
No.

Next time you select a board, instead of considering only the hardware specs or price, perhaps look at the quality of its software support?
ummm

Doesnt really help me understand how to address this issue with SPI include problems

Which incidentally, I've already fixed as I realised that the SAM core has basically got a work aroun in Arduino.h to permanently include SPI.h even if the sketch doesn't include it !

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 20, 2014, 12:21 am
Thanks @john1993

I have to connect RXD on the Serial USB to RX on the board (which I often get wrong as its contrary to what I normally expect) It has RTS but not DTR but it doesnt have 3.3V out, it only has 5V out, hence another reason I tend not to use it.
if you want to skip the button press every time then dtr is required. however for diagnostic purpose i would try it because silabs has no history of flakyness. also unlikely two different types would have same compatibility problem.

3.3v is always available onboard but, again for convenience sake, id suggest ordering "six pin cp2102" from ebay with the extra holes down the sides. cheap and reliable plus they have 5v, dtr, and 3.3v on pins.

did you just say you fixed the spi? is it working? this seems to be the last of the "big 3" protocols.
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 20, 2014, 01:10 am
sues.
I'm running it on 3.3v from my USB to serial, which has worked fine elsewhere, but I will double check the voltage and perhaps try giving it 5v from USB as well.
unless your board has a regulator not recommended. it will damage the chip which is 3.3v or less. if it does have a regulator then unless its true ldo the opposite is true. 3.3v with too much regulator drop will undervoltage which can cause intermittent failure.

as far as clock the bootloader does not use external crystal so that cant be the problem either.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 20, 2014, 01:27 am
@john1993

Re:SPI

Sorry. Its not quite working yet. I don't foresee any big issues, as I think I've got over the problem of integrating an instantiating an object called SPI, but currently its not actually calling the hardware functions

But in theory "all" I need to do is copy the hardware calls out of the existing Hardware SPI class and put them into the new SPI class.

As far as I understand from Ray, and reading the Maple forum, HardwareSPI works, the issue has been that none of the existing libraries that use SPI would work unless you went through renaming SPI to HardwareSPI etc. (well its a bit more complicated, but you get the idea)

So I now have stub functions that please the demo like CardInfo.ino which I hope is most of the battle won.

I was hoping to test the SPI stuff with something more simple than an SD card, as they are notoriously fickle in terms of having the right sort of card etc.
And I looked at driving a 7 segment LED controller, but I've realised that it used ShiftOut

and when I tried to use the LedControl library, it doesnt seem to work, but the hardware seems to be doing as its told, e.g. effectively sending SPI using ShiftOut, so I suspect its a voltage levels issue and that the LED driver chip Max72xx I think, either doesnt like the voltage levels or the clock speed.
e.g. it could be too fast. I'll need to compare it with the Uno.

i.e its running at 400khz, which doesnt sound that fast but may be faster than Uno (but may not be)

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 20, 2014, 01:47 am
I was hoping to test the SPI stuff with something more simple than an SD card, as they are notoriously fickle in terms of having the right sort of card etc.
actually all the card type, even mmc, can read idle status (0x01) and most of the modern ones will read v2 check bytes (0x01 0xaa). imo thats all you need to verify spi. everything after that may get complicated specially with xhc but who cares. so for me sd are the most convenient. also if you want your efforts to gain wide audience best use something everybody has to test. just about all cell phones and cameras have sd.

now that you mention it 74hc595 sr are popular but clocking data out on those is so trivial it can be bit-banged just as easy as using mcu hardware. if you can blink you can talk to 7 seg.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 20, 2014, 02:02 am
@john1993

Thanks for the tip about SPI idle

Re:7 seg leds

I tried to get a MZX7219 based LED strip working but looking at the spec I can see why it wasn't working

Its not the clock speed its the logic levels. The spec seems to suggest that Logic high needs to be at least 3.5V :-(

(see top of page 3  in  http://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf (http://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf) )

so for the moment I'll dig out another device to use or testing that works on 3.3V e.g SD card or NRF24L01

Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 20, 2014, 03:28 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
Which incidentally, I've already fixed as I realised that the SAM core has basically got a work aroun in Arduino.h to permanently include SPI.h even if the sketch doesn't include it !
This, IMO, is not a workaround, it is completely inappropriate.  Essentially, this is placing the include/exclude on the smart linker.  While it obviously works for the Due, it surely was a lazy thing to do.

I am not surprised in Paul's response.  He is a cracker jack programmer but also a business man with the Teensies.  I guess he has a right to be cocky, but the STM32F1 really has no impact on his operation, so a little help would have been appreciated.  Oh, well.

Roger:
Are you still having to include full library paths in the main sketch?  I am perplexed somewhat in reading the 1.5.x library rules and then observing what actually happens when the GUI searches for includes.  IOW, a subordinate library with the same name as an \Documents\Arduino\libraries entry is not selected.  If I remove the duplicate, the subordinate STM32F1XX directory is then selected.  Backward behavior.  But, I may be at fault in my reading of:
Arduino-IDE-1.5:-Library (https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification)

Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 20, 2014, 07:31 am
Quote
I guess he has a right to be cocky, but the STM32F1 really has no impact on his operation, so a little help would have been appreciated.
After my initial surprise about a comment to a programming question, I realized why he's have made such a comment. Although these are slower than the Teensy (probably half as fast, I'm not sure),

The fact that you can get 5 Maple Mini clones on eBay or Aliexpress for roughly the same price as one Teensy, i would have thought pushed some people towards maple mini clones

I've thought about getting a Teensy once or twice, but the cost of the board plus overseas' postage, made it uneconomic for me.
I ended up with 2 x Due's for roughly the same money (as I can get them from eBay china free of postage)



Re: Full paths to libs

As far as I'm aware, there is no need to put in the full paths.

I'll need to double check



Re: Including SPI in Arduino.h

I've just double checked and I'd got this wrong, because there are 2 spi.h for Due.

One is the one in Libraries and the other is the one inside the sam core

I think the include I saw was for the sam core.


For the moment to get SPI working, I think I'll have to leave my hack in place, but in the longer term, I totally agree that leaving it up to the linker is not a professional thing to do.


(Or course there could be no work around, because the IDE may not be looking for files correctly in libraries at the right time, but as Wire seems to work, without this - as far as I'm aware - I'd hope we'd not need to do this hack for SPI)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 20, 2014, 11:03 am
Guys

I've spend some time on SPI this evening, but at the moment its back to not compiling

I took out the include to SPI.h from wirish.h because although it seemed to make a very basic program, compile OK, as soon as I tried to compile a demo like cardinfo I get strange errors about SPI not being defined

So its best to nip this in the bud and not have that dodgy include in the first place


One thing I have noticed, and I'm sure if its relevant, but the platform.txt file that defines all the compile switches etc, is different from the SAM one in ways I wouldnt necessarily expect.

This could be because its changed since 1.5.7 or whatever version Bob Cousins was originally working with, I'd need to either ask bob or try to figure it out

e.g. the platform.txt for STM uses the g++ compilor but SAM uses gcc , I'm not sure what the differences between these are.
I think there are also other compilor switch differences, but its getting too late for me to try to work out what they are

Edit. It looks like SAM uses g++ and gcc and I'm not sure how it chooses to use one or the other.

Either way, there are difference between the platform.txt for STM32 and SAM
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 20, 2014, 02:20 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
The fact that you can get 5 Maple Mini clones on eBay or Aliexpress for roughly the same price as one Teensy, i would have thought pushed some people towards maple mini clones
Of course, some would take the plunge; unknown the numbers.  One thing "we" do not know is the inventory of the STM32F1xx in China in the Maple Mini format.  If the demand off-shore China goes up, then there may be a price increase due to demand.  This did not happen with the Mini 328, but the supply model may be different for the STM device.  My guess is that something happened to cause a glut of STM32F1xx devices to appear in the China supply chains (maybe a cancelled contract, etc.) and some enterprising engineers quickly designed boards to utilize the chip glut.  Whether a future run of boards would hit the same price point is unknown... guess is that it would driven by the availability of STMF1 in quantity... and this chip is a bit long-in-the-tooth, announced in 6/2007.

Paul's Teensy crop of boards is very well supported, so my personal guess is that he commands the higher price due to his success with support... that is, I doubt that his pricing is a deterrent when coupled with the fact that he provides a fully-functioning Arduino'ish environment, forum support, etc.  I've seen at least one Github GLCD repository where the author gave Paul credit for the display SPI routines that he "snatched".  Perhaps Paul is just being overly cautious as the hobby and semi-professional markets are always upset by price-performance.

Ray
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 20, 2014, 04:43 pm
and this chip is a bit long-in-the-tooth, announced in 6/2007.
Wow, didnt realise its a 7 year old design, I think the ATMegas must be older than that, but they are still popular too. Ray do you think its not a good idea to include this chip in new designs ?
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 20, 2014, 04:48 pm
Here's something I noticed... When I compile the following for "STM32 to flash" (normal option), it takes just under 10k of code space.. does anyone know why this is ??

Code: [Select]
void setup() {
}

void loop() {
}
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 20, 2014, 05:28 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
Ray do you think its not a good idea to include this chip in new designs ?
I would ensure that demand for "new designs" per se were backed-up by guaranteed access to inventory: uC native or STM32F1 eval board like the Maple Mini clones. 

I do not have access to the STM32F1 lifecycle from STM but I suspect they will authorize foundry orders as long as they have a a genuine demand and we all know the hobby+maker market does not generate that kind of demand.  The uC is pretty cool, has 20K of SRAM and I suspect it is used in many embedded designs, perhaps digital thermometers, microwaves, etc.  But industrial and consumer equipment gets reengineered every few years to differentiate new models and my guess is that the engineering team will be influenced by STM's roadmap which will likely "steer" them toward designs that are in the 2-3 year age category.

STM32F Roadmap: STM Official - Warning PDF > 1M (http://www.digitimes.com.tw/tw/B2B/Seminar/Service/download/053A110160/053A110160_4VHPYLU9HLIYQW19DQMB.pdf)  (beginning on pg 10)

I can not even make an educated guess on what is going on with the "F" series, but die manufacturing techniques have evolved significantly since the initial production of the 32F and I doubt that STM will retool the design simply to save silicon die size.  More likely, they will just retire the device in the future.

Ray

//Forward reference!
mcnobby
I had to link the PDF because it was > 1MB .... probably just as well.

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 20, 2014, 05:31 pm
I have attached a Road Map presentation for the 32F series (date unknown- no metadata)
Cheers Ray, could you attach please :)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 20, 2014, 09:33 pm
The link worked for me.

Re long term availability

Good point.

I guess I should grab some more maple minis off aliexpress ie at least get 5 more


@mrbrunette (ray)

There are so many stm32f103 variants, most of which look like they would be compatible, with the IDE via serial to USB, I would have thought that there would be supply of at least one of the variants for a while.

I'm no expert on the teensy etc, but...


In terms of these devices being competition for the teensy.
Its hard to say. As soon as you move away from 5v AVR based boards I think you are likely to have issues.

The risk is less with the Due and the Teensy. And Paul tests loads of hardware with the teensy - so if someone intends to use a specific bit of hardware that has been tested its much less risk.

But the teensy is also a single supplier source, even more so than the stm stuff

I'm not sure if Paul manages to make a full time living from the Teensy, I guess possibly, but its a tough market to be in.
So he could of course instantly decide he has a better job offer and stop supporting the teensy as much has he currently does.


I'd have thought the stm32f103 s are always going to be cheaper than a teensy because the processor is based on the m0 core not the m3.

Prices of m3 core STM s seem to be comparable to the teensy.

So it's just really a price and performance point, that doesn't seem to be covered by other Arduino compatible boards. And or course the small form factor is a bonus for some things.

I wonder how much the Arduino Zero would be. I guess it will be slightly cheaper than the due.



Title: Re: What's this I found on eBay?
Post by: Coding Badly on Nov 20, 2014, 09:37 pm
Quote
But the teensy is also a single supplier source...
OSH Park manufactures and sells the Teensy 3.1.

Quote
So he could of course instantly decide he has a better job offer and stop supporting the teensy as much has he currently does.
Which is true for every company on the planet including Arduino.  So what?

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 20, 2014, 09:48 pm
I wonder how much the Arduino Zero would be. I guess it will be slightly cheaper than the due.
Isnt the zero kinda pitched between the teensy 3.0 & 3.1 (performance-wise) ?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 20, 2014, 09:59 pm
Removed my useless comment on the Teensy..



I'll carry on looking at the issues with SPI not seeming to get included.





Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 20, 2014, 10:27 pm
OK

I figured out why #include <SPI.h> is not doing as expected.

Its because the library paths are added at the end of the include list for the compilor, and there are 2 other places in the maple libs that have and spi.h , as the PC is not case sensitive it it finds the first one and starts using it, even though its spi.h rather than SPI.h

But this isn't really a case sensitivity issue is a folder hierarchy issue.

i.e On the maple the included libs are in this order

Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\system/libmaple
Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\system/libmaple/include
Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\system/libmaple/stm32f1/include
Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\system/libmaple/stm32f1/include/series
Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\system/libmaple/usb/stm32f1
Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\system/libmaple/usb/usb_lib
Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\cores\maple
Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\variants\maple_mini
Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\libraries\SPI\src

and its picking up spi.h from

Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\system/libmaple/stm32f1/include/series

rather than the folder

Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\libraries\SPI\src



On the DUE the list looks like this

C:\Program Files (x86)\Arduino\hardware\arduino\sam\system/libsam
C:\Program Files (x86)\Arduino\hardware\arduino\sam\system/CMSIS/CMSIS/Include/
C:\Program Files (x86)\Arduino\hardware\arduino\sam\system/CMSIS/Device/ATMEL/
C:\Program Files (x86)\Arduino\hardware\arduino\sam\cores\arduino
C:\Program Files (x86)\Arduino\hardware\arduino\sam\variants\arduino_due_x
C:\Program Files (x86)\Arduino\hardware\arduino\sam\libraries\SPI

and one of the paths before the last one contain an spi.h or SPI.h


So.. Unfortunately, it looks like I'll need to do some more code and folder re-organisation for this to work, i.e take 10 steps back and then go 11 steps forward.

in order to get SPI to compile


I supposed the optimum solution is to look at the SAM core folder structure and see if the Maple code and be move to a similar organisation

But its not a 5 minute job.

;-(

Basically, I"ll need to modify platform.h and remove the paths to the series include, and I've just started to do that. But of course it doesn't compile because files from series/include are referenced in wirish.h and it cant find them.

One nasty hack I could do is use .. paths in wirish.h and this has precidence in the SAM core as its done all the time for chip.h

So I may do that as an initial fix, but I know its a hack ;-(
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 20, 2014, 10:42 pm
GOOD WORK ROGER !!

So glad you know what you are doing there.. its all a bit french to me, but I am very glad you are on the case :)

Thank you, in advance, for the time in the future when I will need STM32 SPI :)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 20, 2014, 11:16 pm
@mcnobby

I think to get this working in a reasonable timeframe, I'm going to initially do this in a rather hacky way.

But I think as long as it works, it will be ok for the time being, and if anyone has the time to restructure the whole thing at a later date, they are free to download all the code and do it ;-)

It may not in reality be that difficult to do. i.e I just need to initially remove the series/include from the path and then see what needs to be changed in wirish.h etc so that the files in series/include/xxx.h still get included as required.

I don't think its an issue if wirish.h includes /series/include/spi.h before the real lib gets included, as I think its all about the initial search that the pre-processor does in order to find the files.

But I must admit I had to read up on precisely what #include <> vs #include "" does, as I've not generally had to worry about the -I directive with gcc before.


I also took a look at the g++ vs gcc compilor thing, and I don't think its an issue
Apparently gcc calls g++ for c++ files and calls the c compilor for .c files

Though quite why platform.txt for STM32 specifies g++ in one place when SAM doesn't is still a mystery. I guess I could PM Bob Cousins, but I don't want to bother him, as he's not active in this thread

Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 21, 2014, 01:30 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
But I think as long as it works, it will be ok for the time being
Roger that!  :smiley-grin:

Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 21, 2014, 02:53 am
Re: bare minimum (setup and loop) being 10k

Its because there is a load of initialisation stuff called before even main.cpp (which calls setup and loop)

init() is in boards.cpp and looks like this for the maple stuff

Code: [Select]

void init(void) {
    setup_flash();
    setup_clocks();
    setup_nvic();
    systick_init(SYSTICK_RELOAD_VAL);
    wirish::priv::board_setup_gpio();
    setup_adcs();
    setup_timers();
    wirish::priv::board_setup_usb();
    wirish::priv::series_init();
    boardInit();
}

/* Provide a default no-op boardInit(). */
__weak void boardInit(void) {
}

/* You could farm this out to the files in boards/ if e.g. it takes
 * too long to test on boards with lots of pins. */
bool boardUsesPin(uint8 pin) {
    for (int i = 0; i < BOARD_NR_USED_PINS; i++) {
        if (pin == boardUsedPins[i]) {
            return true;
        }
    }
    return false;
}

/*
 * Auxiliary routines
 */

static void setup_flash(void) {
    // Turn on as many Flash "go faster" features as
    // possible. flash_enable_features() just ignores any flags it
    // can't support.
    flash_enable_features(FLASH_PREFETCH | FLASH_ICACHE | FLASH_DCACHE);
    // Configure the wait states, assuming we're operating at "close
    // enough" to 3.3V.
    flash_set_latency(FLASH_SAFE_WAIT_STATES);
}

static void setup_clocks(void) {
    // Turn on HSI. We'll switch to and run off of this while we're
    // setting up the main PLL.
    rcc_turn_on_clk(RCC_CLK_HSI);

    // Turn off and reset the clock subsystems we'll be using, as well
    // as the clock security subsystem (CSS). Note that resetting CFGR
    // to its default value of 0 implies a switch to HSI for SYSCLK.
    RCC_BASE->CFGR = 0x00000000;
    rcc_disable_css();
    rcc_turn_off_clk(RCC_CLK_PLL);
    rcc_turn_off_clk(RCC_CLK_HSE);
    wirish::priv::board_reset_pll();
    // Clear clock readiness interrupt flags and turn off clock
    // readiness interrupts.
    RCC_BASE->CIR = 0x00000000;

    // Enable HSE, and wait until it's ready.
    rcc_turn_on_clk(RCC_CLK_HSE);
    while (!rcc_is_clk_ready(RCC_CLK_HSE))
        ;

    // Configure AHBx, APBx, etc. prescalers and the main PLL.
    wirish::priv::board_setup_clock_prescalers();
    rcc_configure_pll(&wirish::priv::w_board_pll_cfg);

    // Enable the PLL, and wait until it's ready.
    rcc_turn_on_clk(RCC_CLK_PLL);
    while(!rcc_is_clk_ready(RCC_CLK_PLL))
        ;

    // Finally, switch to the now-ready PLL as the main clock source.
    rcc_switch_sysclk(RCC_CLKSRC_PLL);
}

/*
 * These addresses are where usercode starts when a bootloader is
 * present. If no bootloader is present, the user NVIC usually starts
 * at the Flash base address, 0x08000000.
 */
#if defined(BOOTLOADER_maple)
#define USER_ADDR_ROM 0x08005000
#else
#if defined(BOOTLOADER_robotis)
#define USER_ADDR_ROM 0x08003000
#else
#define USER_ADDR_ROM 0x08000000
#endif
#endif
#define USER_ADDR_RAM 0x20000C00
extern char __text_start__;

static void setup_nvic(void) {
#ifdef VECT_TAB_FLASH
    nvic_init(USER_ADDR_ROM, 0);
#elif defined VECT_TAB_RAM
    nvic_init(USER_ADDR_RAM, 0);
#elif defined VECT_TAB_BASE
    nvic_init((uint32)0x08000000, 0);
#elif defined VECT_TAB_ADDR
    // A numerically supplied value
    nvic_init((uint32)VECT_TAB_ADDR, 0);
#else
    // Use the __text_start__ value from the linker script; this
    // should be the start of the vector table.
    nvic_init((uint32)&__text_start__, 0);
#endif
}

static void adc_default_config(const adc_dev *dev) {
    adc_enable_single_swstart(dev);
    adc_set_sample_rate(dev, wirish::priv::w_adc_smp);
}

static void setup_adcs(void) {
    adc_set_prescaler(wirish::priv::w_adc_pre);
    adc_foreach(adc_default_config);
}

static void timer_default_config(timer_dev *dev) {
    timer_adv_reg_map *regs = (dev->regs).adv;
    const uint16 full_overflow = 0xFFFF;
    const uint16 half_duty = 0x8FFF;

    timer_init(dev);
    timer_pause(dev);

    regs->CR1 = TIMER_CR1_ARPE;
    regs->PSC = 1;
    regs->SR = 0;
    regs->DIER = 0;
    regs->EGR = TIMER_EGR_UG;
    switch (dev->type) {
    case TIMER_ADVANCED:
        regs->BDTR = TIMER_BDTR_MOE | TIMER_BDTR_LOCK_OFF;
        // fall-through
    case TIMER_GENERAL:
        timer_set_reload(dev, full_overflow);
        for (uint8 channel = 1; channel <= 4; channel++) {
            if (timer_has_cc_channel(dev, channel)) {
                timer_set_compare(dev, channel, half_duty);
                timer_oc_set_mode(dev, channel, TIMER_OC_MODE_PWM_1,
                                  TIMER_OC_PE);
            }
        }
        // fall-through
    case TIMER_BASIC:
        break;
    }

    timer_generate_update(dev);
    timer_resume(dev);
}

static void setup_timers(void) {
    timer_foreach(timer_default_config);
}
Title: Some progress with SPI
Post by: rogerClark on Nov 21, 2014, 07:43 am
Guys

I've made some progress with SPI

The refactoring of the code so that the low level hardware spi.h file was not included in place of the library SPI.h wasn't quite as problematic as I thought it may be.

I just had to change paths from this

#include <series/adc.h>

To this

#include "stm32f1/include/series/adc.h"


I realise that this is only any good for the f1 series, and really what I need to do is to put #defines around the code, but as it looks like the current boards.txt only has F1 devices and because I've seen other notes in the code, that suggest that F2 may not be fully implemented, I don't think this is going to be something to worry about for the moment


I've done some basics test to see that my changes have not broken any of the existing functionality and as far as I can tell is OK.

Serial.print etc still works fine, delay is working, the IC2 scanner is still working, digitalWrite is still working.

I can now compile the cardinfo example that comes with the IDE and I don't get any errors and it doesn't crash, and it still prints to serial

e.g. this is what it output


Quote
Initializing SD card...initialization failed. Things to check:
* is a card is inserted?
* Is your wiring correct?
* did you change the chipSelect pin to match your shield or module?
But I didnt expect it to work because (1) I don't have any hardware connected and (2) I've just done a hack job to bring HardwareSPI.cpp into SPI.cpp and then copied missing classes from the SAM SPI.cpp / h

So the chances are, even if I connect some hardware its not going to work straight away (well it would be a minor miracle if it did work) ;-)

But the next thing I need to do is to test my SD card reader hardware with the Due, as I suspect it won't work because it has a LV125A level translator on the board, as it is designed to run from 5V signals

i.e it looks like this one from eBay
http://www.ebay.com/itm/261324523747 (http://www.ebay.com/itm/261324523747)

(http://i.ebayimg.com/00/s/MTYwMFgxNjAw/z/aw4AAMXQUmFSfJWL/$_57.JPG)

So I better test that it works with the Due first, to prove it works on 3.3V

But on the whole I'm relatively pleased with the amount of progress towards getting SPI to work.


Edit. I found an old SD (not micro SD) reader that doesn't appear to have any level translation.
Which looks like the one in this photo (from the web)

(http://arduino.alhin.de/images/Module/SDCARD/SD_karte_Due_500px.png)

So I'll try hooking that up to the Due,

And I'll also see if I have any other SPI devices that I can test with. Well I do have several, but I'm pretty sure most of them work with 5V so will have level translators which could be an issue

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 21, 2014, 08:34 am
Re: bare minimum (setup and loop) being 10k
Cheers, I get it now.. I have written alot for t13 (1k flash) and basically that takes 194 bytes with no code !

Quote
But I must admit I had to read up on precisely what #include <> vs #include "" does
I always thought it was the difference between finding h files in the 'IDE' path vs finding h files in the 'CODE' path

:)
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 21, 2014, 08:45 am
I have decided to join the SPI test team, although I will be a bit late as I have just ordered

www.ebay.co.uk/itm/251471703268 (http://www.ebay.co.uk/itm/251471703268)

but I am sure by the time it arrives I will have a swift STM32 programming solution !!

Most of my spare time is taken on an ATmega328 video project at present, sorry :)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 21, 2014, 09:09 am
@mcnobby

Quote
Most of my spare time is taken on an ATmega328 video project at present, sorry :)
No worries.

Most of my time is taken up with work unfortunately.

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 21, 2014, 09:50 am
Most of my time is taken up with work unfortunately.
.. since we started this I have plastered & decorated a whole 3 bedroom house !! lol
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 21, 2014, 02:24 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
#include "stm32f1/include/series/adc.h"
<...>
I realise that this is only any good for the f1 series, and really what I need to do is to put #defines around the code, but as it looks like the current boards.txt only has F1 devices
As I understand the 1.5 architecture, F1 and F2 are simply different cores; therefore:
3rd-party-Hardware-specification (https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification#boardstxt)
and
3rd Party Architecture (https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#working-with-multiple-architectures)

Roger,

Congrats on getting SPI to compile and link properly.  I see we are back to "pathing" concerns that I have been fussing about for such a long time in this thread...
I have yet to get 1.5.8 to (properly) parse through the 3rd party libraries under Arduino\hardware as is detailed in the documentation.  However, for hardware in the \Program Files\Arduino_158 path the search appears to work... and this is where the Due stuff is located, so it pretty much had to work.

Many thanks for your determination and efforts.


Ray


Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 21, 2014, 04:55 pm
I can now compile the cardinfo example that comes with the IDE and I don't get any errors and it doesn't crash, and it still prints to serial
i have a micro sd socket wired for the stm32 ready to go. very simple to make from a micro sd adapter split in half. 6 wires no components. these take about 3 minutes to make. if you tell me what to do id be glad to help with the testing.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 21, 2014, 08:36 pm
Guys,

I will try to commit and push my latest changes to GitHub in the next hour.

It's not really at a point where spi can actually be tested, but the codebase is no worse than what is currently on the server, so I may as well commit it.

The SPI.cpp and SPI.h files are an untested and incomplete amalgam of the Leaflabs HardwareSPI files, with new functions taken from the SAM core, but the actual code in the SAM functions commented out as its SAM specific.

I'm not an expert in this, but beginTransaction and endTransaction where not in HrdwareSPI, so I will need to look at the Arduino API docs to see what function they perform, and then see how to implement it for STM

@mrbrunette

Ok about F2 vs F1.

The changes I made to system/libmaple files, to access the F1 files should be flexible enough to support other cores, using IFDEFs. It should be possible to put a define in via the boards.txt e.g -D SERIES_F1 etc and the pull in the correct files during compile.
But that's a job for way off in the future unless anyone here has an F2 core board they can test with

Actually I may get a Nucleo F4 board at some point, but $50 for a 180mhz F4 discovery board is a bit beyond my budget at the moment when I haven't even got the F1 SPI fully working yet ;-)

And I have just received some ESP8266 modules, which I was hoping to setup a compiler for.
Though the tool chain for ESP8266 is not ARM, and any only runs on Linux, so its not an Arduino project.


Work has been mental this week, with people wanting lots done for pre Christmas releases, but hopefully some time in December I will have more time for all of this non work stuff.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 21, 2014, 08:55 pm
OK

Changes have been committed and pushed to GitHub

You may like to make a backup of the existing files, as although the new files seem OK for me they may not work for you ;-)

I guess if you want to see if you can compile things with SPI in them, its worth a go, but I've no idea if it works yet.

If you have code that doesn't use beginTransaction or endTransaction, it may work because the rest of the code is pretty much lifted verbatim from LeafLab's HardwareSPI.cpp

I may be able attach a scope to my board later to see if it does indeed toggle the appropriate lines, but that won't be before the end of the day for you guys in the USA and Europe.

The day is just starting here in Melbourne, and its forecast to be a hot one, 31 deg C, so I have to put a fence post in before it gets too hot to work i.e before around lunchtime.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 22, 2014, 08:05 am
OK Guys,

I'm truely shocked, but SPI works.

Well, I'll clarify that statement, I had to make one change to my code that I uploaded, to implement beginTransaction and endTransaction, but apart from that, I've just run the cardinfo.ino with no modifications (apart from Serial baud rate as I normally use 115200), and I got this output



Quote
Initializing SD card...Wiring is correct and a card is present.

Card type: SD1

Volume type is FAT16

Volume size (bytes): 511959040
Volume size (Kbytes): 499960
Volume size (Mbytes): 488

Files found on the card (name, date and size in bytes):
TINYFS.IMG    2014-03-10 09:58:28 511959040
I've not tried to write a file etc, but it's looking very promising.

One thing that I don't fully understand is what beginTransaction and endTransaction actually do.

And for some reason endTransaction doesn't seem to be getting called after the last transaction, so currently software select is being left low (not that this seems to be a problem)

I'll need to post to the protocols forum for answers, and the code is not commented enough for me to know what these functions are supposed to do, and they only seem to exist for SAM, which is curious.


I've uploaded the new code

Pins are

SCLK PA5
MISO PA6
MOSI PA7
SS PC13

Note PA5,6 and 7 correspond to hardware SPI1, I put software select on PC13 just because my board has an LED on this pin, and I thought I may be able to see it flashing during transfers.

I'll need to look in the Maple docs to see what pin they use, and then I'll probably move it to that in.

Enjoy !


Edit.

SPI may only work with 1.5.8  , please use this version.

Also it may not work with other programs than cardinfo.ino , I have yet to get to the bottom of beginTransaction etc and also where in the Maple code the SS line is driven low, because basically it doesnt seem to be, unless there is a SS line associated with hardware SPI 1

I'll need to do some more research

Title: Updare on SPI
Post by: rogerClark on Nov 22, 2014, 12:02 pm
I've modified the code on GitHub so that Slave Select is now on PA4 (aka pin 10 on Maple boards)

This pin is called SP1_NSS in the STM docs, as it can be used as either Slave Select output or an an input to control if the STM32 is a master or slave on SPI

For some reason Maple chose not to configure the hardware registers however to automatically drive this pin.

I had a quick look at setting SPI1 Control register 2, to set the NSS pin to SSOE i.e output mode, but it didn't work, so at the moment I'm using digitalWrite in beginTransaction and endTransaction to do the same thing.

However I suspect that only the newer code developed for 1.5.8 uses these functions, so I'll need to go back and see how to get the hardware control of this pin working.

In the mean time, if some existing code doesn't work, just put

Code: [Select]
pinMode(PA4,OUTPUT);
digitalWrite(PA4,LOW);


At the start of your code (assuming you only have 1 device on SPI). If you have more than one device, then you will need to put SS for each devices on separate pins and drive them low accordingly at the correct time ;-)

But either way, I think its for the best if I use PA4 for SS as this is the correct pin to use hardware SS in the long term.

PS. I've not looked at setting the SPI speed etc as yet.


Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 22, 2014, 12:46 pm
VERY WELL DONE ROGER !!!! you deserve a medal !!

I will look at testing in a few weeks when my card boards arrive :)

Cheers, Bob
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 22, 2014, 01:26 pm
One thing that I don't fully understand is what beginTransaction and endTransaction actually do.
it asserts and deasserts the different chip selects for each device on the chain. sometimes just for one packet other times for a long series of packets like data transfer. since its not changed predictably for every packet its not a standard control pin but really just general io needed to be controlled differently by the each app. also since each device needs a different select there cannot be one standard pin for that.

so just unzip the latest file and the stock cardinfo demo should work? must the old stuff be deleted or will it be overwritten?

for my promini the demo worked as-is under 1.0.6 but as i mentioned a week or two back for 1.5.8 needed to include spi.h. whats the deal with maple version? must the example be modified?

the sketch uses "pin 4". is that the same as your pa4? i can wire to any pin for starters.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 22, 2014, 08:24 pm
John1993

If you your sketch already has a digitaWrite in it to control Slave Select pin, you can just connect change it from pin 4 etc to whatever pin you like, (except of course MOSI MISO and SCLK which are on PA5, PA6 and PA7, I can't remember the order, see my previous posting)

Maple maps PIN numbers to the real hardware, and I think pin 10 is PA4 11,12, and 13 are mapped to the corresponding hardware SPI pins, so that the numbers match the UNO I think, however I've not looked in detail.

I recall on Leaflabs wiki they have a table that shows pin assignment.


Also with beginTransaction, you can pass in the SS pin and my code should work on a different pin. However I've noticed that either endTransaction is not getting called or my code is not working, as SS is not being taken high after a transaction.

Also, 1.5.8 AVR core SPI doesn't see to have the transaction code, as far as I can see, but as S2Dcard still compiles for UNO on 1.5.8, I guess it must be there somewhere or s2dcard has some IFDEFs , I will need to check


With the transactions stuff, do old libs that use SPI still work , e.g. Not libs that come with the IDE.

I can't imagine anyone would want to modify them for 1.5.8, most Arduino users don't have the necessary skills to do this.


Title: Micro SD card reader with level translator also works
Post by: rogerClark on Nov 22, 2014, 10:00 pm
Hi Guys,

Just a quick update.

I have tried using my micro SD card adapter module

(http://i.ebayimg.com/00/s/MTYwMFgxNjAw/z/aw4AAMXQUmFSfJWL/$_57.JPG)

which contains the level translation for 5V systems, and it seems to be working OK.

I initially powered the module from 5V, as it has an on board 3.3v regulator, but I've also tested it using a 3.3V as the supply voltage and it works OK that way as well.

I will see if I can find any other SPI devices to test. I think the Nokia 9110 displays use SPI, so I"ll wire one of those up and give it a try later. i.e I want to test third party libraries, not just the ones that come with the Arduino IDE, as I suspect it may not work unless those libs specify the Slave Select pin themselves



Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 22, 2014, 10:02 pm
so bottom line, to duplicate your cardinfo result is it just a matter of unzipping your latest file and run the demo or is it more complicated?

personally if its possible id rather move jumpers around than have to modify examples.

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 22, 2014, 11:44 pm
@john1993


I see what you mean about chipselect being defined as 4 in the cardinfo example

I'd not really looked that high up in the call hierarchy.

Looking in board.h

in the pin's enum

Code: [Select]
enum {
    PA3, PA2, PA0, PA1, PB5, PB6, PA8, PA9, PA10, PB7, PA4, PA7, PA6, PA5, PB8,
    PC0, PC1, PC2, PC3, PC4, PC5, PC13, PC14, PC15, PB9, PD2, PC10, PB0, PB1,
    PB10, PB11, PB12, PB13, PB14, PB15, PC6, PC7, PC8, PC9, PA13, PA14, PA15,
    PB3, PB4
};


pin 4 is PB5

I just moved my SS to pin PB5 and it didn't work,

So I'll look at the code and see whats wrong.

Currently I've been using pin 10, is PA4 as this is the normal SS pin for some other stuff I was using, but now that you've pointed out that CS pin is set in cardinfo to pin 4 I'll see what needs to be changed to get it to work correctly.

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 23, 2014, 12:20 am
@john

I'll need to get back to you on this one.

There is an issue with the pin mapping

The enum for the pins that I have, doesn't seem to match with the pins as defined in Maple's wiki, for either the maple or the maple mini
http://leaflabs.com/docs/hardware/maple.html

http://leaflabs.com/docs/hardware/maple-mini.html

Actually, this is looking more and more confusing.

It looks like the libmaple stuff that was in bob's orginal version was from the IDE, but I've had a response from the one of the Leaflab's repo maintainers and he said that the stuff in github superseds the code in the IDE even though the dates on the IDE is newer than in libmaple

However, looking at libmaple, the code structure is quite a lot different from the code I have (and that I modified)   aaarrrggghhh

It looks like what I really need to do, is to replace my core code with libmaple from github, but I have made hundreds of changes, so its not a simple or quick process.

In the mean time, the best thing to do is to change the pin to use the real device pin name e.g. PB5

and download the latest code from github


Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 23, 2014, 12:28 am
im not really sure what going on with that "enum" business. for example when i ran the blink example pc14 wiggled which dont really look like pin 13 there.

as i said it dont matter too much which pin is which io because since this is a new platform we can wire the hardware up any way we like as long as we tell what pin is what. examples on the other hand are at the heart of arduino. beginners dont know or care what goes on in the background with libraries, ide code, etc  because few dig that deep. so imo the focus should be on changing those demo programs as little as possible so noobs have a fighting chance.

aside from pinout theres other issues. as mentioned a week or two back 1.5.8 was broken for promini in that it wouldnt even compile like it did with 1.5.7. spi.h had to be added to the example to suppress the error.

it would be nice to fix these background problems so at least the classic examples need as little mod as possible.

with only a few minutes a day to work on these things i prefer to wait for dust to settle so let me know when its good for me to give this a try. im certainly in no rush.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 23, 2014, 01:46 am
Hi John1993


I'm not really sure about the, the pro-mini issues. Those changes would be in the core that's in program Files\Arduino\etc

So nothing I do in this stuff would fix that ;-(

I'll just keep on going with the STM32 and hope the Arduino team fix up the core.

BTW. My stuff probably works fine will 1.5.7, but I better go back and check !
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 23, 2014, 09:21 am
@john1993

I check and my SPI code didnt compile under 1.5.7 as it appears that the IDE team removed setClockDivider() when they moved to 1.5.8

So I've added a stub / empty function for this into the code, so that it compiles.

The clock divider is fairly meaningless, as it appears that SD2card.cpp sets this to either 128 or 255, which I presume is 16Mhz / 128 i.e 125khz so 255 would be half of this

The Maple default is much faster i.e 1.25Mhz and the slowest if 140khz, i.e faster than the AVR 128 div speed.

Anyway I've tested several SD cards and they all seem to work ok at the default Maple SPI clock freq


BTW. Re: Pin mappings.

I made a mistake, the code I have does appear to be the latest, though I'm not sure when Bob took his snapshot.



Re: Pin Mapping.

I have double checked and the enum's I posted previously are the latest ones from libmaple.

The issue appears to be the pin numbers that LeafLabs chose for the SPI (and also Wire) connections

e.g. Looking at my Maple mini (clone)...

S_CLK is on pin 6 but this is pin 13 on the Uno etc.
Pin 4 is mapped to MOSI etc

So although the pin numbers match to the Maple hardware, they positively cause issues trying to use pin numbers from existing sketches

Unfortunately, I can't see an easy way around this, so I think its one thing that people will just have to bear in mind if they find something doesn't work.

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 23, 2014, 10:35 am
obviously the important thing is to get things working then address wish list items later.

so what is needed for me to duplicate your sd tests? what zip file, what sketch, and what stm32 signals?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 23, 2014, 10:49 am
@john1993


I've attached the Cardinfo.ino I used. Its the same as the example that comes with the IDE, except I set the SS pin to PB5

SPI connections are on the Hardware SPI 1 channel

i.e
CLK PA5
MISO PA6
MOSI PA7

Its the same as listed on Maple's wiki, but ignore the "D" numbers (unless you are using a maple mini)


It worked straight away for me

I also tested it on 1.5.7 and it didnt initially compile because of the missing function to set the clock divider, but I've put in an empty dummy function to get over this compile error (as it looks like the new IDE will not have this function)

Title: More missing functions :-(
Post by: rogerClark on Nov 23, 2014, 10:53 am
Guys,

I've just noticed that Serial.find("") is not in the files that I have.

When I looked into it, the problem is a bit more complex to fix than simply copying the find function into HardwareSerial, because the issue is actually being caused because HardwareSerial no longer derives from Print it derives from Stream.

This change looks like it happened at Arduino 1.0.x

I thought I could just change my code, so that HardwareSerial derived from Stream, but I get a load of errors which aren't making a lot of sense to me at the moment.

But I'll get back to it tomorrow, as I have a sketch that I want to try that uses find()

Cheers

Roger
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 23, 2014, 03:25 pm
I've attached the Cardinfo.ino I used.
thanks for that. ill give it a try as soon as i get back to my setup.

ive reread the comments about pin mapping but still a little confused. can you summarize again why we cant pick other pins for ss like we could with avr?
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 23, 2014, 04:44 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

<...>
When I looked into it, the problem is a bit more complex to fix than simply copying the find function into HardwareSerial, because the issue is actually being caused because HardwareSerial no longer derives from Print it derives from Stream.
<...>
Roger, I think this is what we call, "Peeling back the skins on an onion..."
Every new layer brings tears when you realize there is more to do.

I give you this, you are one persistent dude.  :D (And the effort is appreciated.) The work would have been tough just for the technology component of AVR 8-bit to STM32-bit, but the changes from pre-Arduino 1.0 to 1.5.x is also creating havoc.

I had not fully appreciated the Cypress Creator (their GUI) for PSoC development until now. In their concept of project, all library files are copied into the working project folder and become tab-able, editable, and searchable. A ZIP archive of the current project then contains 100% of the source and object files required.  With the days of expensive hard disk long passed, I think perhaps Arduino needs to consider doing the same thing... libraries are static folders and copies are made into projects -- therefore, minor tweaks can be made without needing to deal with the original.  The Creator GUI also has a feature that allows for code migration to a new project where libraries (#includes) are re-fetched which allows for library updates to be validated with older, working code using the past library.


Ray
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 23, 2014, 07:55 pm
Just been having a scan on ebay, and found these...

STM32F103C8T6 (http://www.ebay.co.uk/itm/161469494016)

Thats £1.37 each for the 64k flash version (C8 64k, not CB 128k)

Surely this must be one of the best value for money uPs around
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 23, 2014, 09:07 pm
@john1993

I will need to double check, but I have not seen anything in the core code for 1.5.x which sets the Slave Select pin I.e pulls it low during transfers.

The LeafLabs code didn't to it in their lib, and I don't think the 1.5.x SAM code does it either.
But I will check later.

Normally I just use libraries e.g. from adafruit etc to communicate with SPI devices and have not looked under the hood to see what they actually do.

For the SD stuff, the SD2card.cpp file has the digitalWrite to control the SS pin, which you pass as a parameter from cardinfo.ino


Of course the MISO MOSI and CLK lines are fixed as the core of the SPI uses the Hardware SPI channel 1.

The STM32F103 has 2 SPI channels, but I've not looked at how channel 2 could be supported.
So at the moment you are restricted to on channel, e.g like on the AVR
But you can have multiple devices on different Slave Select Pins.



@mrbrunette

Yes. As I pull back the layers, more issues seem to be revealed. BobC did a great job to get something up and running quickly, but in reality to get a fully functioning set of files for these devices, masses more work was needed, and loads still needs to be done.

With the Serial.find issue, I did a bit more research last night, and it looks like I may need to change the structure of hardware serial.
Because although, because of the way it has to inherit from the abstract function in stream.cpp

However it could just be missing functions in hardware series.

I will need to take another look in the cold light of day.



Re:complexity etc

This is light relief from my day job(s)

I'm a self employed developer, I have 2 active projects, one using php, MySQL, JavaScript, HTML 5 etc, the other using C#, java, objective C, C++ actionscript, XML which also requires me to manage a server on the Internet on microsofts Azure cloud system.

By comparison a project that is just C++, isn't that complex, but it is however equally time consuming. ;-)



I initially started this to get a faster platform for motion sensing, but now that I have these boards, I find they are more useful to me for other things.
E.g. I have some ESP8266 wifi modules, and wanted to run an example sketch from seed studio , but found that the example wouldn't run on a UNO as it needs a second serial port running at 115200, which is faster than is possible with software serial.
So I thought I may as well use the STM board as it has 4 serial channels.

Unfortunately this is when I found this issues with serial.find.   ;-(

But I'm sure I will have it sorted later...!

Title: Other code changes.
Post by: rogerClark on Nov 23, 2014, 09:16 pm
Guys

Re other changes

As Leaflabs are still bug fixing and maintaining libmaple, I will merge in their changes sooner or later, I just need to work out a process to list the file differences between what I have an what is no in their Git repo.

I'm waiting for BobC to get back to me, about what date he grabbed the libmaple files, so I can then grab the same revision, and then get a list of diff's to the present date.

I implemented their fix for the wire bug, I'd already found and fixed, even though it makes no functional difference, as its better to keep the code as close to theirs as possible, for maintainability.

I have emailed the guy who maintains it, letting him know what I'm doing, but have yet to hear from him.

I also wonder how many people still use the original Maple IDE?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 23, 2014, 09:39 pm
@mcnobby

I'm not sure it's going to work out any cheaper than buying a maple mini clone

I found some at $4 just now

http://www.aliexpress.com/item/leaflabs-Leaf-maple-mini-ARM-STM32-compatibility/32214664071.html

By the time you include the cost of an 8mhz crystal, I doubt building it from scratch will be much of a saving.

In the longer term however, I can see a use for a second stm32 on the same board.

Have one STM purely for comms with the host PC, aka programming port, like on the due.

I think it would be cheaper to use STM32s for this, than even using the same small avr as used on the Due.

Btw, in this scenario if anyone wanted to do fancy things like keyboard and mouse emulation they would be better off doing it in the main stm32 and just leave the other as a dedicated USB to serial emulator.

Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 23, 2014, 10:29 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
Btw, in this scenario if anyone wanted to do fancy things like keyboard and mouse emulation they would be better off doing it in the main stm32 and just leave the other as a dedicated USB to serial emulator.
Well...
as a side note, I love the PSoC 4200 Prototype board:
PSoC 4200 Prototype (http://www.cypress.com/?rID=92146)
Each $4 board comes with a break-away USB-Serial... these things are great and are Fully Supported in all versions of Windows... signed drivers!  Cypress does not give the source to the CY7C65211 configurable USB bridge controller, but they do have the existing binary available for download.

The trick with any USB-serial is going to be the darn Windows certified/signed drivers, IMO.

As mentioned earlier, I ordered 5 of the STM BAITE boards from AliExpress... about 6 weeks.  All arrived last week, in their little sealed anti-static envelops.

Quote
In the longer term however, I can see a use for a second stm32 on the same board.
This is certainly an interesting thought.  STM may have a less expensive chip that can be China sourced for less than the STM32F103... although the concept of having 2 of the STM32F1xx on the same board "could" be an opportunity to hack some of the current scheduling programs out there and create a kind of hypervisor or abstract hardware layer, HAL.  This actually could make more sense with the floating-point version of the STM, however.  I know Bob (Crossroads) has at least one 2 uC board.  Even if the second chip was primarily for COMMs, the extra I/O could still be controlled over an SPI or I2C channel along with the serial send-receive.


Ray
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 24, 2014, 12:37 am
Hi Ray

The link to that other $4 development board was very interesting.

I agree that Windows certified drivers are the main problem. I'm not sure if a Cypress USB device was used on its own, e.g. with the STM board, whether the Windows driver and code for the USB devices would be included as part of the license agreement just by buying the USB part its self, or whether thats only because its part of the whole development kit.

I took a quick look at STM's DFU drivers package, and as far as I could tell the driver just seemed to be publicly available, but I'm not sure if it would be re-distrubutable or even if it was actually Windows certified.


Using the FTDI gives would have the certified driver. However its just USB to Serial and doesn't have the control lines needed to reset the board unless DRT etc are used, and I'm not sure if thats how the Arduino boards do it.

Having a uP with built in USB that could also toggle the required lines would be a good long term solution, but finding one with some sort of re-usable certified driver may be the problem

One kind of cheeky way to do it, is just to use the USB drivers that are installed by the IDE for use with LUFA on the Leonardo, i.e replicate what the LUFA code does within some other cheaper chip, or perhaps the 16U2 is cheap ??

Edit 16U2's are around $ on aliexpress. Its going to be cheaper to run back to back Maple boards !

Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 24, 2014, 04:47 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

@rogerCkark:
Quote
Edit 16U2's are around $ on aliexpress. Its going to be cheaper to run back to back Maple boards !
We do live in unusual times considering chip prices.

I use many Pro Micros and LUFA works well and is well documented.  Arduino drivers or those by Sparkfun ProMicro (https://www.sparkfun.com/products/12640) could be utilized.  BUT @ $3.52/reel 1500 these are too darn expensive just for software USB.  Mouser list 8U2 at $2.24USD / 4K is simply outrageous.

When one starts digging into the price, I can now understand why so many of Crossroads' board designs utilize user-provided external serial to USB.

I am (still) having good results with the STM32 Maple Mini clone with DFU /serial.... Just a darn shame Windows 8.1 forces "test mode" to be invoked so the drivers survive reboot.


Ray
Title: Re: What's this I found on eBay?
Post by: CrossRoads on Nov 24, 2014, 05:20 am
Quote
When one starts digging into the price, I can now understand why so many of Crossroads' board designs utilize user-provided external serial to USB.
I do it mostly because most things are designed to be embedded and don't need dedicated onboard USB.
And secondly because the USB/serial chips are so damn small, very hard to hand solder.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 24, 2014, 05:24 am
@mrbrunette

Quote
Just a darn shame Windows 8.1 forces "test mode" to be invoked so the drivers survive reboot.
There appears to be a way to sign unsigned driver with a certificate other than the global microsoft one, and then install another certificate into Windows which tells it that the certificate on the driver is to be trusted.

I don't think its that hard to do, but it does need a load of Microsoft developer software in order to create and install the certificates.

If I had more time, I'd give it a go, as I agree the Maple board works really well using its onboard USB.
Its at least as reliable as my external USB to Serial, and much quicker to upload.

But remembering to boot into the special mode in Windows is a pain.
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 24, 2014, 05:53 am
There are a lot of interesting ARM boards out these days.  Sadly, the peripherals Roger is working so hard with are generally NOT common between different vendors :-(

Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 24, 2014, 11:06 am
I think that if the method to port to different ARM boards was well documented it would probably not be too hard to do variants for new hardware.

i.e there are a defined set of things that would need to be ported; Serial, I2C, SPI, ADC, Pin read and write, PWM,timers and time keeping etc.
Other peripherials e,g. CAN bus and D2A would also need to be done on a lot of devices, but I'm not sure if CAN is even supported on Due.

I guess its easier than writing from scratch, but a lot of the issues I'm having are because the Arduino API has changed between 0022 and 1.0.x and is now different again in 1.5.x

Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 24, 2014, 02:26 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
But remembering to boot into the special mode in Windows is a pain.
Whoa, there!
If you put Win 8.1 (I am using Prof 64-bit on a dual-core Intel box) into "Test Mode" the setting persists across power-down and reboots.


Windows Test Mode for unsigned drivers (http://msdn.microsoft.com/en-us/library/windows/hardware/ff553484%28v=vs.85%29.aspx)

Unfortunately, while this old mcse has no issues with 'test mode', many users would likely balk, IMO.


Ray
Title: Re: What's this I found on eBay?
Post by: mrburnette on Nov 24, 2014, 03:28 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

<...>
It looks like the libmaple stuff that was in bob's orginal version was from the IDE, but I've had a response from the one of the Leaflab's repo maintainers and he said that the stuff in github superseds the code in the IDE even though the dates on the IDE is newer than in libmaple

However, looking at libmaple, the code structure is quite a lot different from the code I have (and that I modified)   aaarrrggghhh

It looks like what I really need to do, is to replace my core code with libmaple from github, but I have made hundreds of changes, so its not a simple or quick process.

In the mean time, the best thing to do is to change the pin to use the real device pin name e.g. PB5
and download the latest code from github
Quote
As Leaflabs are still bug fixing and maintaining libmaple, I will merge in their changes sooner or later, I just need to work out a process to list the file differences between what I have an what is no in their Git repo.
@Roger:
I use a program called WinMerger (free-open source), now in version 2.14.0.0 and it has not only the ability to view side-by-side individual files for differences but also the ability to scan all the files in a folder for differences!  This is really a wonderful feature because you can drill-down from the higher-level view.  Highly recommended.


Ray


Added:

Just as one of my last posts until after Thanksgiving holidays here in the U.S., compiled Roger's post of SD Card Test. Here are the libs that went into the compile:
Code: [Select]


C:\Users\ThisUser\AppData\Local\Temp\build8995460697145869977.tmp\SPI>prompt $g

>find "D:" *.*

---------- SPI.CPP.D
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\libraries\SPI\src\SPI.cpp \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\libraries\SPI\src\SPI.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/libmaple_types.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/spi.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/rcc.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/stm32f1/include/series/rcc.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/nvic.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/util.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/stm32f1/include/series/nvic.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/stm32.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/stm32f1/include/series/stm32\
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/stm32f1/include/series/spi.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/boards.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/wirish_types.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/gpio.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/stm32f1/include/series/gpio.h\
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/exti.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/stm32f1/include/series/exti.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/timer.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/stm32f1/include/series/timer.\
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/libmaple.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/delay.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/bitband.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/adc.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/stm32f1/include/series/adc.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\variants\maple_mini/board/board.h\
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/wirish.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/WString.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/avr/pgmspace.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/avr/interrupt.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/io.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/bit_constants.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/pwm.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/ext_interrupts.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/wirish_debug.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/wirish_math.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/wirish_time.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple/systick.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/HardwareSerial.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/Print.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/WString.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/boards.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/stream.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/HardwareTimer.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/usb_serial.h \
 D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple/Print.h

---------- SPI.CPP.O
►↑ (08D:\Documents\Arduino\hardware\STM32\STM32F1XX\libraries\SPI\src\SPI.cpp
☺D:\Documents\Arduino\hardware\STM32\STM32F1XX\libraries\SPI\src
D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include/libmaple
D:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/stm32f1/include/series
D:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple
D:\Documents\Arduino\hardware\STM32\STM32F1XX\libraries\SPI\src\SPI.cpp

>
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 24, 2014, 07:22 pm
I do it mostly because most things are designed to be embedded and don't need dedicated onboard USB.
And secondly because the USB/serial chips are so damn small, very hard to hand solder.
and last but certainly not least, checking some mcu forums, about half the download problems are due to hardware and software issues with on-board usb interfaces. this thread a perfect example. with sillabs and prolific dongles being so cheap, trouble free, and.... prolific... the huge obsession with built-in usb is a mystery.
Title: Windows drivers
Post by: rogerClark on Nov 24, 2014, 09:07 pm
@mrbrunette

Windows 8.1 must be better in this regard than Windows 7. My machine keeps reverting back, each time I reboot :-(


Re: merging

I have WinMerge and also BeyondCompare.
But I first need to work out when BobC took his snapshot, otherwise it won't be able to know what files Leaflabs have changed in the last month. AFIK they have made at least a dozen changes since mid Oct when BobC started the original work on this project.


STM F4 168mhz on order!
Yes. I've ordered a F4 based Discovery board on Sunday from an eBay supplier in Germany. Deliver date should be within a week.
I will keep you guys posted.

One interesting thing. Although the F4 has a FPU its not double precision. This is not STMs decision it's the Arm core M4, so the Due etc will be the same is suspect.


Looking at STs docs on the differences between F1 and F1 I think most things should work, but I will know more when I get the board.

I also ordered a cheap STLink USB adaptor, as my Jtag programmer has still not arrived an it looks like I will need to open an eBay issue against the supplier as the are no longer responding to messages.


@john1993

I have still not worked out why one of my boards is so intermittent at entering bootloader mode.
I looked at the signals on my scope, and the data from the USB to serial into the board is clean and has the correct voltage levels.

I'm going to connect serial 2 on one of my working boards to my flakey board, and see if it responds to that board because you just need to send it 7f hex and its supposed to respond with 79

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 25, 2014, 02:24 am
maybe diagnose by changing everything except the bad board. different download utility, different pc, different serial adapter, different os etc.. if its still flaky then just write it off. these are so cheap maybe better to put off investigating that for a rainy day.

ive just had problems with my pc and moved over to a duplicate system to see if it was the software. worked fine so it wasnt the image. swapped each component separately and of course turns out the last one suspected was the bugger. bad power supply of all things. not dead, just marginal enough to cause my windows to misbehave. silly to waste all that time troubleshooting. should have just switched over to the good computer but it is satisfying getting to the bottom and now i have 2 good setups again.

hopefully i can pick up where i left off in the morning.
Title: Re: What's this I found on eBay?
Post by: Docedison on Nov 25, 2014, 02:26 am
That was my #1 excuse to quit early.... It nearly always worked..

Doc
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 25, 2014, 04:56 am
@john1993

I did a quick experiment, connecting Serial1 on my working STM32 the one where the uploads are extremely flakey and observed the RX and TX lines on my scope when I sent code 0x7F to the flakey board.

The pattern of 1's and 0's from the STM32 (rather than the USB to Serial) is completely different, and the flakey STM32 seems to respond straight away.

I'm not sure what a 7F should look like, in terms of a waveform, but they are definitely different and I think the flakey board prefers the 7F from the other STM32 board
Title: New version on GitHub
Post by: rogerClark on Nov 25, 2014, 12:05 pm
Hi Guys,

I've pushed a new version to GitHub

This version adds missing functions to Serial, specifically peek() and find().

Actually, its a bit more of a major change, as to bring in find(), I had to replicate the class inheritance in Arduino 1.0.x where HardwareSerial inherits from the Stream class instead of the Print class.

I've not extensively tested it, but I think its all working.

But the Stream class, probably adds more functions than just find() to Serial, so feel free to let me know if something doesn't work.


On a totally different subject.

My experiments with using one STM32 to write serial bootloader data to another STM32, was no more successful than using a USB to Serial adpater.

It looks like my STM32F103RCT board is somehow faulty, so I will wait until my STLink clone arrives, to see if I can program it that way.

My previous posting about different waveforms when sending 0x7F from the STM, was a red herring. I think Serial.print(0x7f) seemed to be sending some other character, and using Serial.write(0x7F), gave the same waveform that I saw from the USB to Serial adapter.

Other things

BobC has got back to me with the GitHub commit number, so another day, I'll be able to compare files and see what else needs to be updated to bring in recent fixes made by the Leaflabs guys.

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 25, 2014, 02:45 pm
The pattern of 1's and 0's from the STM32 (rather than the USB to Serial) is completely different, and the flakey STM32 seems to respond straight away.
great trick. so it looks like your usb/serial adapter may be at fault. using a different adapter should fix that. trying two different types pretty much guarantees success because problems with these are rare. those $1-$2 ebay "6 pin cp2102" with holes down the sides are pretty much trouble free. out of hundreds.thousands of users no case of driver issues yet.

btw if you post photos of the scope traces i can tell you exactly which are correct. ive also been using hyperterminal to experiment with the boot protocol (CD00264342.pdf). quite a thrill to see that 'y' return.

anyway it looks like you have overcome most of the major issues adapting stm32 to arduino. the "big 3" protocols are working so the rest looks like trivial details (famous last words). now might be a good time for people to start checking out the examples. at least thats my plan as soon as i get back from work. thanks again for all the effort youve put into this.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 25, 2014, 08:01 pm
with 562 posts, this is currently the second 'most posted' topic currently on this forum
Not bad for something only started 10 weeks ago !!

I was bored while eating my pudding... :)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 25, 2014, 08:26 pm
@john1993

I agree that testing and also documentation is what is now needed.

I'd not be surprised if some things are either missing or not working.

I only cake across the issue of Serial.find() being missing, when I tried to compile an example from seed studio.

SPI probably needs more work, as I've not looked at whether it works on SPI hardware channel 2, and not looked at clock rates.


I have also realised that the stream.cpp I'm using is from 1.5.7 but they changed it in 1.5.8 however I'm not sure what has changed.


Version 1.5.x etc, also seems to be a moving target, with new functions being added like Serial.availableForWrite, which looks like it returns the number of bytes available in a Serial output ring buffer. However the stm32 doesn't have an output ring buffer, and I'm not sure whether this is a feature that was in 1.0.x, as I've not had time to check that codebase.

Although the stm32 has more ram, I'm not sure whether implementing more buffers is very beneficial, especially for Atmega328 devices where ram is severely limited.
Even the current situation of input buffering will I suspect be very wasteful of ram on the STM32 because there are 4 hardware serial channels.
I will need to check the code to see how these buffers are allocated.

Normally when I write code for my day job, I would not allocate static buffers, and use "lazy instant inaction" of objects, but because the Arduino API has all the Serial objects as globals, the only way around this would possibly be to allocate the input buffers using malloc from inside Serial.begin.

I suspect someone must have already though of this.

I know malloc seems to generally frowned upon in Arduino circles, because its misuse can cause memory fragmentation, but its the only way I can see a way around allocating loads of unused static buffers.

So I'm tempted to take a look at modifying the code.

Title: Can we get the moderators to rename this thread.?
Post by: rogerClark on Nov 25, 2014, 08:29 pm
Guys,

This has been mentioned before, but perhaps either we need to start a new thread or get this one renamed.

Its title is not very explanatory any more.

I know the moderators don't like cross posting or duplicate postings, but perhaps now that the codebase is at a beta stage an available for testing, perhaps they would allow another thread, with a title on the lines of


STM32 port now available for testing
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 25, 2014, 08:33 pm
can you hang it out for a couple of dozen more posts so that this gets to #1 ? ;)
Title: Re: What's this I found on eBay?
Post by: Coding Badly on Nov 25, 2014, 08:44 pm
Quote
...perhaps they would allow another thread...
Perhaps.   :smiley-twist:

Quote
I know the moderators don't like cross posting or duplicate postings...
Primarily because cross-posting makes it difficult to provide help and wastes peoples' time.  Neither of which is true in this case.

Quote
...perhaps now that the codebase is at a beta stage an available for testing, perhaps they would allow another thread, with a title on the lines of
STM32 port now available for testing
Sounds good.


When this sort of thing comes up, I suggest using Report to Moderator.  It's just dumb luck that I noticed your post.

Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 25, 2014, 09:04 pm
normally id vote for a new name instead of new thread because a lot of useful info and links here would be lost. however since you are not the op a new thread makes sense because its very important to keep post #1 current and that cant be done if you are not the author.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 25, 2014, 10:13 pm
It's just dumb luck that I noticed your post.
(lol) @CodingBadly... I noticed you read this thread. I didnt expect to be able to cross post without it getting noticed, especially as I mentioned those words in my post ;-)


I'm happy for whatever people feel is the best approach, if renaming is better, thats fine.

But I think the title needs to change

Does anyone any ideas for a better title ??
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 25, 2014, 10:28 pm
Its probably good to have as many useful keywords in the title as you can, to make it easier when searching

perhaps use words like STM32F1 & MapleLeaf too
Title: Re: What's this I found on eBay?
Post by: john1993 on Nov 25, 2014, 10:28 pm
the title you mention seems hard to beat. however as mentioned i think a new thread is better so that you can update the first post with important info. i think people underestimate the importance of that.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 25, 2014, 10:31 pm
I agree about the Maple and STM32, but I'm looking to port to STM32F4 when my Discovery F4 board arrives (probably next week)

So I think we need to omit the F1 bit ;-)
Title: Analogue input
Post by: rogerClark on Nov 25, 2014, 10:46 pm
Guys,

I thought I'd see if any of the basic examples that come with the IDE work, and it the AnalogReadSerial doesn't work straight out of the box.

Its because an additional line needs to be added

Code: [Select]
pinMode(inputPin, INPUT_ANALOG);

I'll need to see how the AVR and SAM cores handle this, as I they don't seem to need to set the Analog pin to be an input on the AVR, which I've always found to be slighly odd, as its necessary for the digital pins.

One way around this is to do the "lazy" method, of keeping track of whether the pin as been set to Analog input, and if an analogRead occurs and the pin as not been set to this mode, it would first
call pinMode(inputPin, INPUT_ANALOG); and then actually read the pin

This of course would involve an extra if statement in the analogRead function, which would slow things down a few clock cycles, and also I'd need to put a buffer in to store which pins had been set to Analog input, or possibly read back the pin state from the hardware (if thats possible) but that could be slow as well.


One way around the speed issue is to add a #ifndef STM_NO_CHECKING  (or something like this) around the code that does all this additional work, so that if you did #define STM_NO_CHECKING it could disable a load of things, including the other stuff in the GPIO which does bounds checking on digitalWrite and pinMode etc

I know this is non-standard, but its worth thinking about.

Also...


Not many Analog pins actually appear to be free because of the way they are shared with the other hardware.
For example the first 4 analogue channels, are shared with Hardware Serial Channel 2.

Fortunately it appears that the MapleCode doesn't configure the Serial channels until you call begin, so hopefully on generic STM boards these will be available unless you use Serial 2.

I'll need to read the Maple docs again, because as far as I can see, they don't make it very clear about the duplicate use of pins
e.g. This is their page on analogRead

http://leaflabs.com/docs/lang/api/analogread.html (http://leaflabs.com/docs/lang/api/analogread.html)

which could catch you out unless you read this page

http://leaflabs.com/docs/hardware/maple.html (http://leaflabs.com/docs/hardware/maple.html)

Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 26, 2014, 12:02 am
You know Roger, by the time you have finished, you may have debugged some very odd behaviour of the Maple boards and made them so usable they'll become popular!
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 26, 2014, 12:19 am
You know Roger, by the time you have finished, you may have debugged some very odd behaviour of the Maple boards and made them so usable they'll become popular!
I must admit, the Maple guys did loads of work, but didn't seem to worry about compatibility with existing Arduino sketches.

I think that for things like analogueRead etc, it would be better if it just worked "out of the box", so even though its slower I may just add code to do the pinMode stuff inside analogue read, but also put in that #ifndef in however for advanced users who need the speed (i.e us)
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 26, 2014, 12:50 am
Just to check... Do the hardware serial ports come up as serial unless you define them as Analogue readable by pin mode? Do the Arduinos do it the other way around?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 26, 2014, 01:22 am
It looks like the Hardware serial ports are not configured by LibMaple unless you call Serial.begin

However, the pinMode is not set even by analogRead, which means that a lot of existing libraries won't work "out of the box" also pins A0, A1 A2 A3 are not defined

I'm not sure what libs use analogueRead, i know the eMonLib for power measurement, uses them, but I can't recall if you specify the pin numbers in the constructor, I'll need to check.

I'm not sure how valid it would be to define A0 for example to hardware Analog channel 0, as this is also used by Serial2

But the changes are people would probably not be using HardwareSerial 2, and if they did, they'd probably have an understanding of how to change the library or use HarwareSerial 3 etc.

Adding code to check for conflicts is probably not a viable option as it slows things down, and the key thing about these devices is speed and memory, and adding this sort of idiotproof checking will consume both of these resources

Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 26, 2014, 10:34 am
Ah I see the problem. Using analogue read on the Arduino sets the pinmode, and is used that (lazy) way in libraries, but on the Maple, you need to set it first.... That is a bit of a pain.
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 26, 2014, 12:08 pm
@chillitronix

I'm not sure how the AVR boards handle the setup. I thought that possibly the pins were configured in the pre-init called before main()

However looking at the AVR code, it looks like the pins are initialised each time analogRead is called

well, there is this code in analogRead

Code: [Select]
ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5);

And in 1.5.7, the SAM (Due) code has this in it

Code: [Select]

adc_enable_channel( ADC, ulChannel );
// Start the ADC
adc_start( ADC );


which again looks like it calls the setup stuff just before it actually does the actual analog to digital conversion.


The Maple code looks like this

Code: [Select]
uint16 adc_read(const adc_dev *dev, uint8 channel) {
    adc_reg_map *regs = dev->regs;

    adc_set_reg_seqlen(dev, 1);

    regs->SQR3 = channel;
    regs->CR2 |= ADC_CR2_SWSTART;
    while (!(regs->SR & ADC_SR_EOC))
        ;

    return (uint16)(regs->DR & ADC_DR_DATA);
}




I suspect to make the Maple code behave like the Arduino API, that the pinmode would basically have to be put into the function before it does the current functionality.

Interestingly there is this structure "adc_dev" which is passed in.lthought its marked as const, I wonder if that refers to the content of the struct or the struct pointer (I suspect the latter, but I'd need to double check... I don't program in C for my day job ;-)

I'm a bit loathed to just put a call to pinmode into the top of this as it would slow it down, but there may be a way to put something into the dev structure to indicate if a call to pinmode is necessary, and that would waste less clock cycles

Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 26, 2014, 03:55 pm
I downloaded and started reading the STM32F1 instruction set (for assembly language) - there are some really really powerful instructions in there, so when I get to it I will have to get my head round a whole new assembly compiler, as I am sure it wont be anything like AVR

I recommend anyone else who is also interested in the assembly side to also have a look, since I have never programmed in 32bit before it came as quite a shock, but also quite exciting ;)
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 26, 2014, 09:33 pm
@mcnobby.
Can you post a link to that doc.



Re: Leaflabs still updating their Git repository

I've pulled the libmaple repo onto my PC and used BeyondCompare to see the file changes that Leaflabs have been doing over the last month.

There have been at least 10 updates. There appear to be 4 or 5 small bug fixes, where additional checks have been put into the code.
There are changes in order to remove compiler warnings, but I don't see any warnings when the Arduino IDE compiles. So I will check the warning level that is defined for the Arduino build vs the Maple IDE, and see whether its worth pulling those changes through.

There are also comments in the changes about preparing for F4 support, where some functions have been moved from one file to another.
But I'm not sure if I can replicate their changes in this regard, because I've already had to move quite a lot of files in order to bring the structure and hierarchy in line with the current Arduino version ( and Arduino 1.0.x for that matter)


I have emailed the guy at Leaflabs who seems to be managing the updates, several days ago.
As it would be good to know what they are doing.

But I have not had a reply :-(

I took a look on Leaflabs website, but nothing has changed, no big push for a anything new f4 based Maple or anything like that, but I guess anything is possible.

There are email addresses of other contributers in the commit comments, so I will try emailing those guys, to see if I can get more information.


I don't know why they are updating code for the old Maple IDE which is still based on the Arduino 0022 build and the old API. I would understand it if they were updating the code to add 1.0.x functionality, but that's not what they appear to be doing.

I also took a look on Sparkfun, and the Maple mini and Maple are still for sale at ridiculously high prices, however the last comment from anyone who bought one, as 2 years ago, and the last reply to the comment was 1 year ago!


I think perhaps their push is to support more board, but on the old IDE, as I've seen references to boards like the Olimex in the IDE and I'm not sure if that was there originally.





On a totally different subject

I posted to STM own forum to clarify the source code license to their CPAL library that has code for things like hardware I2C, but even the guy from STM who seems to give corporate answers has not replied.
So I'm still none the wiser about the intention of the license conditions, and whether snippets could be used.
E.g to get CAN bus support etc.
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 26, 2014, 09:53 pm
@Roger, just to get this straight, in the Arduino world, if I do an analogue read, the pinmode is set when I do that? That must waste a few clock cycles. That said there are quite a few on the Maple boards!
Title: Analog input
Post by: rogerClark on Nov 26, 2014, 10:26 pm
@chillironix

I'm not entirely sure what the AVR or SAM (Due) does when you call analogRead, but if you look at the SAM (Due) code...

Code: [Select]

uint32_t analogRead(uint32_t ulPin)
{
  uint32_t ulValue = 0;
  uint32_t ulChannel;

  if (ulPin < A0)
    ulPin += A0;

  ulChannel = g_APinDescription[ulPin].ulADCChannelNumber ;

#if defined __SAM3U4E__
 switch ( g_APinDescription[ulPin].ulAnalogChannel )
 {
 // Handling ADC 10 bits channels
 case ADC0 :
 case ADC1 :
 case ADC2 :
 case ADC3 :
 case ADC4 :
 case ADC5 :
 case ADC6 :
 case ADC7 :
 // Enable the corresponding channel
 adc_enable_channel( ADC, ulChannel );

 // Start the ADC
 adc_start( ADC );

 // Wait for end of conversion
 while ((adc_get_status(ADC) & ADC_SR_DRDY) != ADC_SR_DRDY)
 ;

 // Read the value
 ulValue = adc_get_latest_value(ADC);
 ulValue = mapResolution(ulValue, 10, _readResolution);

 // Disable the corresponding channel
 adc_disable_channel( ADC, ulChannel );

 // Stop the ADC
 //      adc_stop( ADC ) ; // never do adc_stop() else we have to reconfigure the ADC each time
 break;

 // Handling ADC 12 bits channels
 case ADC8 :
 case ADC9 :
 case ADC10 :
 case ADC11 :
 case ADC12 :
 case ADC13 :
 case ADC14 :
 case ADC15 :
 // Enable the corresponding channel
 adc12b_enable_channel( ADC12B, ulChannel );

 // Start the ADC12B
 adc12b_start( ADC12B );

 // Wait for end of conversion
 while ((adc12b_get_status(ADC12B) & ADC12B_SR_DRDY) != ADC12B_SR_DRDY)
 ;

 // Read the value
 ulValue = adc12b_get_latest_value(ADC12B) >> 2;
 ulValue = mapResolution(ulValue, 12, _readResolution);

 // Stop the ADC12B
 //      adc12_stop( ADC12B ) ; // never do adc12_stop() else we have to reconfigure the ADC12B each time

 // Disable the corresponding channel
 adc12b_disable_channel( ADC12B, ulChannel );
 break;

 // Compiler could yell because we don't handle DAC pins
 default :
 ulValue=0;
 break;
 }
#endif

#if defined __SAM3X8E__ || defined __SAM3X8H__
 static uint32_t latestSelectedChannel = -1;
 switch ( g_APinDescription[ulPin].ulAnalogChannel )
 {
 // Handling ADC 12 bits channels
 case ADC0 :
 case ADC1 :
 case ADC2 :
 case ADC3 :
 case ADC4 :
 case ADC5 :
 case ADC6 :
 case ADC7 :
 case ADC8 :
 case ADC9 :
 case ADC10 :
 case ADC11 :

 // Enable the corresponding channel
 if (ulChannel != latestSelectedChannel) {
 adc_enable_channel( ADC, ulChannel );
 if ( latestSelectedChannel != (uint32_t)-1 )
 adc_disable_channel( ADC, latestSelectedChannel );
 latestSelectedChannel = ulChannel;
 }

 // Start the ADC
 adc_start( ADC );

 // Wait for end of conversion
 while ((adc_get_status(ADC) & ADC_ISR_DRDY) != ADC_ISR_DRDY)
 ;

 // Read the value
 ulValue = adc_get_latest_value(ADC);
 ulValue = mapResolution(ulValue, ADC_RESOLUTION, _readResolution);

 break;

 // Compiler could yell because we don't handle DAC pins
 default :
 ulValue=0;
 break;
 }
#endif

 return ulValue;
}


Its clearly calling a function called adc_enable_channel(  ); each time, which actually just does this

Code: [Select]

p_adc->ADC_CHER = 1 << adc_ch;


And looking at the Atmel docs it has this

#define ADC_CHER_CH0   (0x1u << 0)
(ADC_CHER) Channel 0 Enable

i.e Its calling "enable" on the ADC channel each time.


I'm not an expert on the SAM architecture, and it could be that you need to enable the ADC channel each time before you read it, however this seems unlikely to me.

So I suspect that what the SAM (and probably the AVR) code is doing is setting up the analog input each time you do a analogRead rather than doing it in pinMode like Maple do.


I think this goes back to the original intention of the Arduino platform to be a learning platform and one for "artists" etc, and the original designers, probably never envisaged that people would be doing things like using the ADC to capture sound etc.


To keep the STM version as close to the Arduino API as possible, I think I'll need to add the code to do the pinMode stuff inside analogRead.

However there is nothing to stop me adding additional functions not in the API, e.g. analogeReadFast() or something like that, which doesnt set the pinMode (and could have other optimisations)

I'm keen not to make unilateral decisions over these sorts of important things, and would like input from the forum. But I think with only 2 or 3 active participants I'm not sure its going to be possible

Perhaps I should just put the pinMode stuff in there and then people can complain later ;-) ... At least it would be compatible with the current Arduino API.


PS.

I'll post to the programming section about analogRead speed and why pinMode is not needed, perhaps someone who reads those threads will know the answers
Title: Emailed some other LibMaple contributers
Post by: rogerClark on Nov 26, 2014, 10:31 pm
Guys,

I've emailed 2 other addresses listed on the GitHub commit comments, to see if they can enlighten me about what's going on with LibMaple.

I did spot a comment about STM Discovery, in one of the recent commits, and there are also changes in preparation of separate code for STM32F1 and for "STM32F2 - F4"

So I suspect that someone (possibly Marti) has a STM32F4 Discovery board, and is making changes to libmaple to support it.

However Marti has not replied to my email, so I've no way of knowing.


I'll keep the forum posted if I find out more.
Title: Re: What's this I found on eBay?
Post by: mcnobby on Nov 26, 2014, 10:45 pm
@mcnobby.
Can you post a link to that doc.
I think this was it : STM32F1 Programming Manual (http://www.st.com/web/en/resource/technical/document/programming_manual/CD00228163.pdf)
Title: Re: What's this I found on eBay?
Post by: westfw on Nov 26, 2014, 10:47 pm
Quote
The pattern of 1's and 0's from the STM32 (rather than the USB to Serial) is completely different,
The ST ROM bootloader does autobaud, IIRC.  Bad things would probably happen if it guesses the bitrate wrong, and there may be some bitrates that work better than others?
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 26, 2014, 11:25 pm
@westfw

Re: My posting
Quote
The pattern of 1's and 0's from the STM32 (rather than the USB to Serial) is completely different,
On further inspection, the issue with different patterns was being caused because I wasn't using Serial.write(char).

Once used write() it looked the same, but I still had intermittent results.

I just looks like the board is both defective due to things like faulty switches, but I'm also wondering how good the design is, e.g it looks lilke Boot may be floating.

Unfortunatly when I was trying to "buzz" connections to the pins on the uiP using my multimeter, I managed to push the solder between the pins and short a load of them together.

fortunatly my USB to Serial 3.3V output won't produce much current and the supply voltage collapsed, so I'm not sure if I'm damaged the uP or not.

I've now cleaned the solder that got pressed between the pins on the uP, and I'll need to try it again, but I suspect I've probably destroyed it :-(
Title: Re: What's this I found on eBay?
Post by: rogerClark on Nov 26, 2014, 11:54 pm
@chillitronix etc

I'm not sure when I'll get chance to test this, but I wonder what would happen is I wrote this and ran it on a Uno

Code: [Select]

pinMode(A0,OUTPUT);

Serial.println(analogRead(A0));


If this still reads A0 then the code in analogRead is setting the pinMode

And of course I could do this

Code: [Select]

digitalWrite(A0,HIGH);// This would turn on the 22k internal pullup, if it exists on these pins, but still lave the board in input mode (assuming I've not already run the other code)

Serial.println(analogRead(A0));
Title: Requested name change of thread
Post by: rogerClark on Nov 27, 2014, 12:52 am
Hi Guys,

I think we all agree that the thread title is now not very explanatory, so I've requested a name change, to

STM32, Maple and Maple mini port to IDE 1.5.x


I will leave it to the moderator gods to let us know if they fell this is acceptable ;-)
Title: Re: What's this I found on eBay?
Post by: ChilliTronix on Nov 27, 2014, 01:47 am
I may get a chance to run that tomorrow.
Title: Re: Requested name change of thread
Post by: Coding Badly on Nov 27, 2014, 09:08 am
STM32, Maple and Maple mini port to IDE 1.5.x
I will leave it to the moderator gods to let us know if they fell this is acceptable ;-)
Done.  I have no idea how replies will be affected.

Title: Re: What's this I found on eBay?
Post by: Coding Badly on Nov 27, 2014, 09:10 am
(lol) @CodingBadly... I noticed you read this thread.
Only have time to skim.

Quote
I'm happy for whatever people feel is the best approach, if renaming is better, thats fine.
Either way is fine with me, too.

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Nov 27, 2014, 09:52 am
@Coding Badly

Thanks



It looks like replies are picking up the new title as well.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Nov 27, 2014, 10:09 am
Just trying to figure out what the AVR analogRead does in terms of setup

Code: [Select]

pinMode(A0,OUTPUT);

Serial.println(analogRead(A0));


This causes analogRead to return zeros'


Code: [Select]
digitalWrite(A0,HIGH);// This would turn on the 22k internal pullup, if it exists on these pins, but still lave the board in input mode (assuming I've not already run the other code)

Serial.println(analogRead(A0));


This appears to turn on the pullup, (as you'd expect)

And constantly returns a number around 1000 but not 1023


I'll need to see if the Due does anything different

I think the issue on the STM32 is that there are loads of internal channels but only a limited number of pins on the chip to access those functions.

e.g as soon as you need to use Hardware Serial Channel 2, this takes up 4 pins on the device that could be used as Analogue to Digital inputs.

Perhaps the best solution is to default Analogue Channel 0 to 4, to analog input, but in Serial.begin make sure that the equivalent of PinMode is called to revert the pins back to the correct operation.

The Maple code may already do this, as the Serial channels are not init'ed until Serial Begin is called on each one of them, which is an efficient way to do it.

I guess I'll need to do some testing on the STM to find out if setting pinMode to Analog input on a Serial channel gets overwrittem when Serial begin is called.

If so I'll add code in pre_init () to setup the Analogue inputs on at least channels 0 to 4

However the other channels are more problematic as I think they are shared with Serial 1 or possibly SPI etc



Title: "Throbbing" LED
Post by: rogerClark on Nov 28, 2014, 12:09 pm
Hi Guys,

Just in case anyone else encounters this little documented feature in LibMaple.

There are various ASSERT statements in LibMaple which seem to get triggered if you try to do something on a particular pin which is not possible.

In my case I was trying PWM analogWrite on pin PC13 - as this is where my generic STM32 has one of its LEDS.

Anyway, the Maple LED (I forget which pin its attached to) started to faded brightness up and down several times a second, and I tracked this down to an error reporting function called throb()

What seems to happen, is if there is an ASSERT in the code, it attempts to output a message via a USART but for me this seems to fail, so it then calls throb() where the code execution ends in a while(1);


I'm not sure why it can't find a USART, I've not debugged that code, but if anyone sees this "throbbing" led, you will know that its not a crash (which is what I initially thought) and its a deliberate error notification from the board.
Perhaps it would be best if it flashed morse code or something.... but I suppose throbbing is better than nothing ;-)
Title: Got my STM32F103RCT board working
Post by: rogerClark on Nov 30, 2014, 12:28 pm
Guys,

I finally fixed my STM32F103RCT board.

It looks like there were several issues

1. The Boot0 and Boot1 switch on the PCB didnt work, so I've removed it and permanently soldered boot0 to Vcc for the moment.
2. I don't know for sure, but it appears that boot1 was floating and that the switch merely pulled it high.
So I've pulled it low via a 1k resistor

Now that I made these 2 changes, I can get reliable uploads and things like Serial work OK. I have not tested anything else.

PS I also made the mistake of removing the surface mount reset switch, thinking it may be defective, but it wasnt, and when I tried to solder it back onto the board, i damaged one of the pcb tracks :-(

So I had a nightmare of a job to try scraping away the solder resist / varnish on the track and soldering a tiny strand of wire to the track and then to the switch.

Fortunately the fix worked, and the board is working and I can upload directly from the IDE
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Nov 30, 2014, 06:19 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

@roger: re: STM32F1xx Maple Mini

Congrats... I'm back from holiday, downloaded your latest ZIP and expanded, brought up 1.5.8, loaded the ASCII chart print over SerialUSB, and it all worked perfectly 2nd time (see note below.)  Huge advance for my Maple Mini... loading correctly from within the Arduino 1.5.8 GUI via the maple_upload.bat script. (Note: I had to add one line to the file, "D:" because my Documents and Arduino home is off on drive D.  I suggest you consider adding "C:" in the file as a placeholder for users who may also have done the same as I... so it is obvious what to change.)


Many thanks. 

This is beginning to feel viable now although I realize that it has taken a lots of sweat on your part to get to this point.  (Thanks also to Bob Cousins and all others involved.)

Ray



Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Nov 30, 2014, 08:57 pm


Hi Ray,

Can you tell me what you had to change to get it to work?

I have not changed the Maple upload bat file, so I suspect this is an existing bug

I'm sure there must be an environment variable to retrieve the path to the My Documents folder, if that's what the issue is.
Title: Float vs Double
Post by: rogerClark on Nov 30, 2014, 10:02 pm
Guys,

FYI

I did some simple speed tests, and one thing to bear in mind is that the STM32 maths uses double precision floating point for functions like sqrt()

When I did test like this

Code: [Select]
 
float c;
for(i=0;i<100000;i++)
  {
    c=sqrt(c);
    c=c*c;
  }


The STM32 only came out 1.65 times faster than a Uno
And the Due only came out 1.64 times faster the Uno (yes the STM32 was marginally faster, but i've no idea why this is)

I thought this was odd, so I looked at sqrt() and the normal C implementation is for it to be double precision.

So I tried this sqrtf  (note the f at the end)

Code: [Select]
 
float c;
for(i=0;i<100000;i++)
  {
    c=sqrtf(c);
    c=c*c;
  }



And this shows the STM32 as 4.23 times faster - which is what you'd expect based on CPU clock rate.

using sqrt   - the double version and all vars as floats, gives a slighly better speed result, at 1.92 times faster than the Uno, as its not having to convert doubles from sqrt back to floats


But I think the lesson, is to be aware that to get the best performance on floating point, use the "f" versions of maths functions, if they are available.

Or if you don't care, but want to use the normal calls e.g. sqrt()  use the double type as this will still be faster than using the float data type

 
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: westfw on Dec 01, 2014, 12:01 am
It's a bit sad that the STM32 only scales at "clockrate" rather than "clockrate*4"
I think that implies that the library code is doing bitwise multiply and divide, when it ought to be able to do 32bits at a time :-(   (The AVR Float library is supposed to be "highly optimized" for the chip; perhaps the ARM library we're using is the generic gcc library...)
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 01, 2014, 12:15 am
Well, unmodified code runs at clockrate x 1.6 (ish)

This isn't the fault of the compiler or the libs, its just that AVR had "modified" libs so that the standard functions like sqrt were actually single precision sqrtf versions in disguise

So that when you put the same code on a uP where the functions correspond to the normal C standard for non-embedded systems, there are bound to be performance issues.


I think however that you are implying that even double precision maths should go faster than 2 x speed of the 16Mhz AVR boards ?

Looking on the web, it appears that most systems use 64 bit for double
( https://en.wikipedia.org/wiki/Double-precision_floating-point_format (https://en.wikipedia.org/wiki/Double-precision_floating-point_format) )

So this is going to take more than one fetch to get the data etc

However as the AVR is 8 bit and float will be at least 16 bits, it would have to do something similar.

So in this case, I would agree that I'd expect more than 2x performance above the speed of the Uno

It will be interesting to see how fast the F4 is when my board arrives, as it has an FPU, but apparently only a single precision fpu, so the float data type should be fast, but double will remain fairly slow (except that the F4 clock is over 2 x the F1 clock !)

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: westfw on Dec 01, 2014, 12:31 am
The Gnu SW floating point library is pretty ... opaque.  It does look like it tries to use the full width of available math instructions, though.

(My claim is that on AVR, if you do a float single precision multiply (~24bits of mantissa), you have to do several 8bit multiplies to get a result.  And division; there's no divide instruction at all, so you're looking at 24 loops through a bitwise division algorithm.  ARM CM3, otoh, has 32bit multiply AND divide instructions, so it should be significantly faster even at the same clock rate just by being able to use those wide instructions...)
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 01, 2014, 01:01 am
@westfw

I guess we'd have to look at each maths function (even the simple ones like multiply) in isolation and compare the performance on AVR and STM32

BTW. The Due is no better than the STM32 and actually in my tests it was slightly slower.

Also.. I did look at the compiler optimization settings as its set at  -Os  i.e optimise for size. I tried changing this for -O2 but the differences were marginal, so I changed it back.

I also looked at the other compilor settings like -ffunction_sections, but the code goes slower if I remove these directives (but it still seems to compile and run OK)

I think BobC probably just took the platform.txt file from the Due, as from what I recall when I was changing the library include paths lookup stuff, it was very similar e.g. -ffunction_sections etc was defined


There may be other compilor settings that would improve performance, but I couldnt see what settings Maple were using in their full IDE, as I don't think platform.txt was the method to define these things back in Arduino 0022.

The easiest way to figure out their settings is probably just to install their hacked 0022 IDE and take a look at the verbose output.



On a totally different point really.. The compilor setting for warnings is set to -w  which appears to be disable all warnings

I tried removing it, and there are 2 or 3 warnings about re-definitions, but nothing major

I think some of the latest updates to LibMaple were to address this.  So in the fullness of time I may get chance to pull those changes into my git version and then enable warnings.

PS. Personally I don't like warnings in code, it usually points to bugs, though in this case I think its just redefinitions, so I'm not worried.


Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: westfw on Dec 01, 2014, 02:49 am
Quote
The Due is no better than the STM32 and actually in my tests it was slightly slower.
You're using the same compiler and math libraries, right?  The arm-gcc that Atmel provides, rather than a separate compiler just for the STM?
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 01, 2014, 03:30 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

The floating point issue is an old one:
http://forums.leaflabs.com/topic.php?id=852#post-5145 (http://forums.leaflabs.com/topic.php?id=852#post-5145)

Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 01, 2014, 05:05 am
Thanks Ray,

On interesting comment in the responses is

Quote
A new link-time optimizer has been added (-flto). When this option is used, GCC generates a bytecode representation of each input file and writes it to special ELF sections in each object file. When the object files are linked together, all the function bodies are read from these ELF sections and instantiated as if they had been part of the same translation unit. This enables interprocedural optimizations to work across different files (and even different languages), potentially improving the performance of the generated code.
So I could give that a try.

However ultimately the results was what I'd expect. If you use floats and lib calls for floats, its 4 x as fast as a Uno for a 4.5 x clock speed.

Using floats with functions like sqrt (and sin and cos etc) will be the slowest and worst option as the double function takes longer to run and the result from those functions gets downgraded to a single precision float, thus wasting even more time.


Like WestFW says, functions like mult should be fast even as doubles, so I'll need to run some tests on those.

Overall, I'm not concerned. But I guess anyone less technical will wonder why a 72Mhz device appears to be about as fast as a 25Mhz device when using some unmodified code.



PS. The PIC UNO32 that was referenced in that posting, could well have been optimizing out some parts of the tests, or their compiler could just be better than gcc

It wasn't clear whether anyone had revisited the test code to guarantee that stuff had not been optimized out
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: westfw on Dec 01, 2014, 05:51 am
Quote
The PIC UNO32 that was referenced in that posting, could well have been optimizing out some parts of the tests, or their compiler could just be better than gcc
The PIC32 compiler is also gcc, although they might have their own soft float library.  The optimizations
(Hmm.  At some point, the ChipKit people switched from using some Microchip proprietary libraries, to an all-open-source-library system.  I had mostly assumed that that meant the libc stuff endup up with newlib or newlib-nano; I wonder if they were using proprietary float libraries as well (and I wonder if they remembered to replace them, if they were.)

I'll have to check whether there's a way to tell exactly which libraries the compiler sucks in, and which version, and how they were built...  (But so far, I'm not even certain which of the {armv6-m/ armv7-ar/ armv7-m/ armv7e-m/ thumb/} libgcc.a's are involved.  Sigh.)
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 01, 2014, 02:24 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

For some purposes, this library which was referenced in my previous link may be useful.  I do not use much FP, so I really do not care much about the performance as long as it is faster than AVR.

https://code.google.com/p/libfixmath/ (https://code.google.com/p/libfixmath/)


Quote
This is a tried and tested cross platform fixed point maths library.

It has been used in projects such as:

Dingoo SDK
AstroLander (Included in Dingoo SDK)
FGL: Flatmush/Fixed-point Graphics Library
This library implements the math.h functions in fixed point (16.16) format, a subset of the currently supported functions are:

sin, cos, tan
asin, acos, atan, atan2
sqrt, exp
mul, div
sadd, ssub, smul, sdiv (saturated arithmetic)
I related library libfixmatrix which utilises libfixmath for matrix operations can be found here: https://github.com/PetteriAimonen/libfixmatrix
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 01, 2014, 05:40 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Hi Ray,

Can you tell me what you had to change to get it to work?

I have not changed the Maple upload bat file, so I suspect this is an existing bug

I'm sure there must be an environment variable to retrieve the path to the My Documents folder, if that's what the issue is.
So, if we are talking about uploading over serial-USB to the Mini, the trick is that both of the unsigned drivers must be loaded and working:  One to enumerate the Comm port (12 in my case) and the DFU driver must be available, too.  The serial DTR causes the MAple to reset and then the DFU takes over to do the real BIN upload to Flash.  Afterward, the COMx port is reset so that SerialUSB will work.

I am using Win 8.1 64-bit Professional and I have my environment set for Test Mode, as you will recall.

Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 01, 2014, 08:42 pm


Hi Ray,

You mentioned you needed to change something because your files e.g I think My Documents, or the Arduino folder is on D: not C:

If you had to change something in one of the files could you let me know what you changed.

Or perhaps I'm mixing this up with a problem someone else reported.



@all

When anyone gets a chance, can you let the forum know if a specific function or piece of hardware works or doesn't work.

I have not had chance to test anything else, as I've been working on an based solar hot water controller for a friend.

I did try hooking up a Max7219 led display driver from that project but it didn't seem to work, however in have not had chance to figure out why not. However I suspect its because the spec quotes min voltage for logic high as 3.5v, which would obviously be incompatible with a 3.3v device.

I may add a couple of transistors to do the signal level translation and try again
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 02, 2014, 01:32 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
If you had to change something in one of the files could you let me know what you changed.
Filename: serial_upload.bat
Code: [Select]
@echo off
rem

Rem If your \Documents\ is on a drive other than C: change the next line
C:
rem parameters are:
rem Note: %~dp0 get path of this batch file, so path parameter is no longer required
cd %~dp0
rem: the two line below are needed to fix path issues with incorrect slashes before the bin file name
set str=%4
set str=%str:/=\%
stm32flash -g 0x8000000 -b 230400 -w %str% %1
rem C:\Python27\python.exe stm32loader.py -e -w -p %1 -g -b 115200  %str%

rem ------------- use STM's own uploader
rem ---- Need to remove the COM bit from the comm port as the STM prog just wants the number
set commport=%1
set commportnum=%commport:COM=%
rem --- The maple board may nee the -i setting to be -i STM32_Med-density_128K or STM32_Med-density_64K
rem ---- 64 bit version
rem "%ProgramFiles(x86)%\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe"  -c --pn %commportnum% --br 230400  -i STM32_High-density_256K -e --all -d --fn %str% --a 0x8000000 -r --a 0x8000000

rem  -- 32 bit version
rem "%ProgramFiles%\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe"  -c --pn %commportnum% --br 2
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 02, 2014, 03:23 am
Thanks Ray,

It looks like you added

Code: [Select]
Rem If your \Documents\ is on a drive other than C: change the next line
C:


I'll need to echo out the contents of %~dp0 as I guess that's set by the IDE,

And can't be a full path i.e doesn't contain the C:\ or d:\ etc

curious ...

Title: Other Arduino 1.5 STM ports seem to exist on GitHub
Post by: rogerClark on Dec 02, 2014, 03:38 am
Just by accident I stumbled across another port of STM32 to Arduino 1.5

https://github.com/MakerLabMe/STM32_Arduino_Cores (https://github.com/MakerLabMe/STM32_Arduino_Cores)

Translation of their info page

https://translate.google.com.au/translate?sl=auto&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&u=http%3A%2F%2Fwww.makerlab.me%2Fguides%2F2&edit-text=&act=url (https://translate.google.com.au/translate?sl=auto&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&u=http%3A%2F%2Fwww.makerlab.me%2Fguides%2F2&edit-text=&act=url)

Their sales website is http://makerlab.taobao.com/ (all in chinese)


Looking at the code, they have put SPI as a library, but its unclear whether they made the other changes necessary for the normal examples like CardInfo to work. They seem to imply that they only tested it with a logic analyser and not to any real hardware

Also, they were advocating copying into teh installation folder (not sure why as they said to use Arduino 1.5.x)

The only think that possibly may be useful is the OSX upload, as they seem to have Mac files as well as Windows files.


But, they have not updated anything for 9 months, so I guess perhaps they gave up.




Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 02, 2014, 09:46 am
Code: [Select]
Ray,

Can you test this revised serial_upload.bat for me

I've tried to extract the drive letter from the path to the batch file ~dp0

It seems to work OK for me, but my My Documents folder hence the Arduino folder is on C:

Cheers

Roger

[code name="serial_upload.bat"]@echo off
rem: Note %~dp0 get path of this batch file
rem: Need to change drive if My Documents is on a drive other than C:
set driverLetter=%~dp0
set driverLetter=%driverLetter:~0,2%
%driverLetter%
cd %~dp0
rem: the two line below are needed to fix path issues with incorrect slashes before the bin file name
set str=%4
set str=%str:/=\%
stm32flash -g 0x8000000 -b 230400 -w %str% %1
rem: C:\Python27\python.exe stm32loader.py -e -w -p %1 -g -b 115200  %str%

rem: ------------- use STM's own uploader
rem: ---- Need to remove the COM bit from the comm port as the STM prog just wants the number
set commport=%1
set commportnum=%commport:COM=%
rem: --- The maple board may nee the -i setting to be -i STM32_Med-density_128K or STM32_Med-density_64K
rem: ---- 64 bit version
rem: "%ProgramFiles(x86)%\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe"  -c --pn %commportnum% --br 230400  -i STM32_High-density_256K -e --all -d --fn %str% --a 0x8000000 -r --a 0x8000000

rem:  -- 32 bit version
rem: "%ProgramFiles%\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe"  -c --pn %commportnum% --br 230400  -i STM32_Med-density_64K -e --all -d --fn %str% --a 0x8000000 -r --a 0x8000000


Title: OneWire library not working
Post by: rogerClark on Dec 02, 2014, 11:05 am
Guys,


I thought I'd see if the OneWire library works, but of course it doesn't


However I can see an issue with getting a version that works for all platforms.

The current version is maintained my PJRC (Teensy), so code would need to be accepted by them, and they'd also need to accept the board type of STM32F1XX

The latter issue is probably going to be a bit stumbling block, because this designation for these boards is something I thought up.


So, Alternatively,  I could just bundle a modified version of OneWire in the libraries folder for this hardware, but unfortunately the IDE looks in the users libraries folder first and then looks in the hardware libraries

So people would have to remove their user library version before the IDE would find the one in the hardware folder.

Anyway, I won't have time to do it now, so I'll look at OneWire in a day or two, to see what needs to be done.


The code appears to use a load of preprocessor macros for

Code: [Select]
#define PIN_TO_BASEREG(pin)             ((&pin))
#define PIN_TO_BITMASK(pin)             (1)
#define IO_REG_TYPE uint8_t
#define IO_REG_ASM
#define DIRECT_READ(base, mask)         (*((base)+512))
#define DIRECT_MODE_INPUT(base, mask)   (*((base)+640) = 0)
#define DIRECT_MODE_OUTPUT(base, mask)  (*((base)+640) = 1)
#define DIRECT_WRITE_LOW(base, mask)    (*((base)+256) = 1)
#define DIRECT_WRITE_HIGH(base, mask)   (*((base)+128) = 1)


I suspect that just using digitalRead and digitalWrite would be fast enough, or alternatively there there is a "Fast digital" library for Maple that I could add to the core code and then use that.

Actually I've found a load of different implementations for GPIO stuff, and I'm sure one of them would be OK.

Anyway, Watch this space....
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 02, 2014, 03:25 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Code: [Select]
Ray,

Can you test this revised serial_upload.bat for me

I've tried to extract the drive letter from the path to the batch file ~dp0

It seems to work OK for me, but my My Documents folder hence the Arduino folder is on C:

Cheers

Roger

[code name="serial_upload.bat"]@echo off
rem: Note %~dp0 get path of this batch file
rem: Need to change drive if My Documents is on a drive other than C:
set driverLetter=%~dp0
set driverLetter=%driverLetter:~0,2%
%driverLetter%
cd %~dp0
rem: the two line below are needed to fix path issues with incorrect slashes before the bin file name
set str=%4
set str=%str:/=\%
stm32flash -g 0x8000000 -b 230400 -w %str% %1
rem: C:\Python27\python.exe stm32loader.py -e -w -p %1 -g -b 115200  %str%

rem: ------------- use STM's own uploader
rem: ---- Need to remove the COM bit from the comm port as the STM prog just wants the number
set commport=%1
set commportnum=%commport:COM=%
rem: --- The maple board may nee the -i setting to be -i STM32_Med-density_128K or STM32_Med-density_64K
rem: ---- 64 bit version
rem: "%ProgramFiles(x86)%\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe"  -c --pn %commportnum% --br 230400  -i STM32_High-density_256K -e --all -d --fn %str% --a 0x8000000 -r --a 0x8000000

rem:  -- 32 bit version
rem: "%ProgramFiles%\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe"  -c --pn %commportnum% --br 230400  -i STM32_Med-density_64K -e --all -d --fn %str% --a 0x8000000 -r --a 0x8000000



[/code]
Roger,
The script seems to work on my 2 disk partition Win8.1 setup.  I started out with "Blink"
and did a single compile & load from the GUI.  The DTR reset the Mini, DFU took over,
and at the end of the load the serial port (12) came back online.

Ray

Code: [Select]

[quote]D:\Documents\Arduino\hardware\STM32/tools/win/maple_upload.bat COM12 1 1EAF:0003 C:\Users\Ray\AppData\Local\Temp\build4230829496114054444.tmp/Blink.cpp.bin
maple_loader v0.1
Resetting to bootloader via DTR pulse
Searching for DFU device [1EAF:0003]...
Found it!

Opening USB Device 0x1eaf:0x0003...
Found Runtime: [0x1eaf:0x0003] devnum=1, cfg=0, intf=0, alt=1, name="DFU Program FLASH 0x08005000"
Setting Configuration 1...
Claiming USB DFU Interface...
Setting Alternate Setting ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
bytes_per_hash=278
Starting download: [##################################################] finished!
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
error resetting after download: usb_reset: could not reset device, win error: The system cannot find the file specified.

[/quote]



ADDED: All Maple Examples (attached) now compile without error on GUI 1.5.8

Path: \Documents\Arduino\hardware\STM32\examples

Near the top of each sketch, I also added the compile-time stats for the sketch in the form of:
Sketch uses 12,484 bytes (11%) of program storage space. Maximum is 108,000 bytes.

What does not work?
- Classes (Functions) that inherit from the Print class
- New 1.0 functions that did not exist in older versions such as Serial.ParseInt()
- Many external libraries for Arduino
- And so forth....
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 02, 2014, 10:36 pm
Ray,

I don't think you can be using the latest version (or I have a problem uploading to the GitHub repo)

I modified a load of stuff to do with Serial and Print at least a week ago (probably longer), so that Serial has find() and parseInt etc or any functions that some from the Stream base class


There are likely to be other things that are missing, but its too time consuming to go through the reference trying out all the functions one by one ;-)

So I'm generally fixing stuff when I notice that its missing or that it doesnt work.

e.g. I have a Nano based project that uses OneWire, so it would be good to get the same thing working on STM32 hence I'm looking at modifying the OneWire library



Re: Uploading

Did you modify the maple_upload.bat file as well as the serial_upload, to fix the issue with My Documents being on D: ?

because I just looked in maple_upload and it should have the same issue, as it just does cd %~dp0 like serial_upload.bat does


Code: [Select]
cd %~dp0
java -jar maple_loader.jar %1 %2 %3 %4 %5 %6 %7 %8 %9




let me know if that needs the same fix

Thanks

Roger
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 03, 2014, 01:49 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
I don't think you can be using the latest version (or I have a problem uploading to the GitHub repo)
Pulled it on 20141201.
But I will "repull" tmo and retry the Serial.ParseInt()

Quote
Did you modify the maple_upload.bat file as well as the serial_upload, to fix the issue with My Documents being on D: ?
No.  Interesting.
Apparently, My configuration of USB/DFU is not using that batch script when I download over USB-serial.

Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 03, 2014, 04:08 am
uumm

Not sure why the DFU stuff is working if serial upload was not working.

It should be using maple_upload.bat as its defined in boards.txt e.g.
Code: [Select]

maple.upload.tool=maple_upload



very strange...

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 03, 2014, 10:49 am
Guys,

I've just been looking at analogWrite and the difference between the Arduino API and the Maple IDE and I can see that this could catch a few people out, because there is a special pinMode or PWM that needs to be set and also the range of values of 0 to 65535 i.e 16 bit instead of 0 to 255 (8 bit)

Maple actually also has a function

void pwmWrite(uint8 pin, uint16 duty_cycle);

and analogWite is just #defined to pwmWrite

So..

I think that in order for more of the normal API stuff to work straight out of the box, I'm going to change the LibMaple code so that analogeWrite is a function in its own write but calls pinMode and then calls pwmWrite

This will slow things down, as the pinMode is only needed the first time, so I'm also tempted to change the struct that hold details of what each pin is setup to do



Code: [Select]
typedef struct stm32_pin_info {
    gpio_dev *gpio_device;      /**< Maple pin's GPIO device */
    timer_dev *timer_device;    /**< Pin's timer device, if any. */
    const adc_dev *adc_device;  /**< ADC device, if any. */
    uint8 gpio_bit;             /**< Pin's GPIO port bit. */
    uint8 timer_channel;        /**< Timer channel, or 0 if none. */
    uint8 adc_channel;          /**< Pin ADC channel, or ADCx if none. */
} stm32_pin_info;


by adding a property called mode, where I can store whether the pinMode has been set to PWM etc

hence I can check more quickly whether the pinMode needs to be set.


The same functionality is required for analogRead, because the Maple (STM32) doesn't have dedicated input pins like the AVR series (and the SAM) appear to have.


Anyway with PWM, I will leave the pwmWrite function intact and somehow document that if you want to change PWM quickly, then setup the pinMode yourself first and then use pwmWrite as it will be quicker as it doesn't call pinMode


To be honest, I think its just me and mrbrunette now left on this thread, so I could be talking to myself, but I thought I may as well say what I intend to do.

BTW. Perhaps I need a wiki for this.

I may be able to build a simple one into github .


Edit.

I've now made the changes to analogWrite as described above.

The fade.ino example works, as long as you change the pin to something that supports PWM

e.g. change the pin from 9 to PA0 works fine.

Code: [Select]
/*
 Fade

 This example shows how to fade an LED on pin 9
 using the analogWrite() function.

 This example code is in the public domain.
 */

int led = PA0;           // the pin that the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
  // declare pin 9 to be an output:
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // set the brightness of pin 9:
  analogWrite(led, brightness);

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}


PS. I made a couple of other changes, I've stored pinmode for each pin, so that in the future I can optimise the issue with having to call pinMode inside analogWrite to set pinMode to PWM (as PWM is not an Arduino pin mode in the normal API.)
I've also defined __STM32F1XX__ in boards.h in preparation for modifying the OneWire library, but I'll explain that in another post, as I've not fixed that library yet

Anyway, download the latest version for increased compatibility  !
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 03, 2014, 03:35 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

uumm

Not sure why the DFU stuff is working if serial upload was not working.

It should be using maple_upload.bat as its defined in boards.txt e.g.
Code: [Select]

maple.upload.tool=maple_upload


very strange...
Yes, I agree... because I was wrong! 
The same changes to serial_ are required in maple_

I pulled the GitHub this morning and compiled & uploaded by serial USB the fade example and received the error:
Code: [Select]
Sketch uses 10,664 bytes (9%) of program storage space. Maximum is 108,000 bytes.
D:\Documents\Arduino\hardware\STM32/tools/win/maple_upload.bat COM12 1 1EAF:0003 C:\Users\Ray\AppData\Local\Temp\build4024062777435503283.tmp/Fading.cpp.bin
Error: Unable to access jarfile maple_loader.jar


I kept a ZIP of the installation before I used the GitHub to overwrite and going back to the image from yesterday, the maple batch file does not have the "fix".  Today it requires it.  The only difference today is a reboot late yesterday because of Microsoft updates.


Quote
I modified a load of stuff to do with Serial and Print at least a week ago (probably longer), so that Serial has find() and parseInt etc or any functions that some from the Stream base class
I did more testing. 
The Serial1 does inherit the parsing properties and compiles without error. 
However the issue, for some reason SerialUSB does not.  Example:

error: 'class USBSerial' has no member named 'setTimeout'
error: 'class USBSerial' has no member named 'readBytes'
error: 'class USBSerial' has no member named 'parseFloat'
error: 'class USBSerial' has no member named 'parseInt'


Ray

UPDATED:
Re: SerialUSB
In thinking through this on my 2nd cup of coffee, there really is not a problem with the current behavior.  That is, the hardware serial ports are the only project needed serial ports - that they work as they should is enough.  The SerialUSB, In My Opinion, is just a "debug" port while programming.  From a project prospective, I see very little use for this connection.  The USB programming via the GUI IDE and the serial debug over USB to a console terminal is 99% of what I need.  I can easily utilize a hardware serial port for any other needed serial connection.

I edited this script to loopback to Serial1 and SerialUSB.  Using my Arduino home-brew serial testset, QBF Serial Testset (http://www.hackster.io/rayburne/the-qbf-signal-generator), I was able to get a decent loopback on Tx1 as well as a copy via USB into the GUI Monitor or TeraTerm.  For my purposes, this is fantastic. Video of test (https://www.youtube.com/watch?v=3pRmr0TmP-w)
Code: [Select]

int inByte;                     // Byte read from Serial1

void setup() {
    // Initialize Serial1
    Serial1.begin(9600);
}

void loop() {
    // Read from Serial1, send over USB:
    if (Serial1.available()) {
        inByte = Serial1.read();
        Serial1.print(inByte, BYTE);
        SerialUSB.print(inByte, BYTE);
    }
}
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 03, 2014, 08:19 pm
Hi Ray

I will update maple_upload.bat, its an easy change

Re:SerialUSB

My mistake. I've mainly been using non Maple boards for my testing, and use A USB to Serial adaptor, so I had not noticed that SerialUSB class inheritance also needs to be updated.

I will take a look, as I'm sure it's possible to fix, but it may not just be a case of changing the inheritance, as I'm pretty sure I have to add new functions to SerialUSB like I had to do with Hardware Serial, to support the peek() function amongst others.

I hope the SerialUSB has an input ring buffer like Hardware Serial has, otherwise its going to need even more of a rewrite.

;-)

Edit

I've added the fix to maple_upload.bat


Re: SerialUSB

Thinking about this, I had initially hoped to rename SerialUSB to Serial, as this would make the API a lot more compatible with the Arduino API.

I can probably also just #define SerialUSB back to Serial, so that code with SerialUSB in it would continue to work

I'll take a look at that after I've figured out how to update SerialUSB to make it support the 1.0 API e.g inherit from Stream.cpp and also added peek() etc

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 03, 2014, 09:34 pm
I could be talking to myself,
there are probably at least few dozen if not hundreds "silent majority" following every word but too shy to make noise. i suspect noisemakers chilli, nobby, westFM, et al are still checking progress too.

As for me aside from having been temporarily relocated to another part of the country for holiday a lot of the talk recently is on usbserial which is of less interest. i use the mfg bootloader since there are lots of issues with the maple one and i prefer path of least resistance. also compounded by the fact that my github link is misplaced atm and im too lazy to hunt it down through this megathread. personally i prefer tutorials where the author has control over first post and can keep it updated for quick reference. no so fond of the repository method of scattering files over the net.

if it will make you feel better i can check in twice daily to let you know how appreciative we are of all your hard work. lol. seriously though, imo this is the biggest development to come along in a while and hope we all see it through. i would contribute more but less experience with the arduino innards sometimes has me feeling that was a stone best left unturned. too late for me to go back now though.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 03, 2014, 10:09 pm
@john1993

No worries

Its good to know that its not just me and Ray (aka mrbrunette). I don't need constant gratification, but its good for people to chip in now and again (one every few weeks would be enough !)

I'm not keen on making unilateral decisions, as although I develop for a living, its easy to make mistakes and also go down the wrong path in terms of what seems to work for me, but won't suit other people.

Hence why I'm posting about what I'm doing


I agree however that following this thread is not easy, and that individual postings to blogs with tutorials etc is much easier for anyone new to the subject to pick up and use.
Hence I did the youtube video and also postings on my blog, albeit I've not updated the blog for a couple of weeks, as I didnt think there was anything that major to report.


Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 03, 2014, 10:11 pm
Ray,

I've uploaded a partially complete fix for the SerialUSB so it should at least compile with sketches that use the new functionality that was introduced with the 1.0. API,

i.e I've now inherited SerilUSB from Stream

However peek() and flush() don't do anything at the moment

I'll need to come back and fix the later today if I have time

But things like SerialUSB.find() now work ;-)
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: ChilliTronix on Dec 03, 2014, 10:35 pm
I am watching with interest and if I have anything useful to say, I will! Outstanding work!
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: cyclegadget on Dec 04, 2014, 02:22 am
 Roger and everyone working the project,

 I am thankful that the STM32 chips are finally being cracked to work with Arduino. I bought this board from Olimex https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/open-source-hardware


 I was very impressed with the features and the possible performance but, sadly it was a pain to try to use when compared to an Uno or a Mega. I also have a couple other STM boards that are even harder to use at my Novice level.

 Keep up the good work! I have been watching this thread nearly daily and I have been able to follow so of it. Somethings being done are well above my understanding but, it is still interesting and promising


Thanks,
Mark
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 04, 2014, 03:17 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Ray,

I've uploaded a partially complete fix for the SerialUSB so it should at least compile with sketches that use the new functionality that was introduced with the 1.0. API,

i.e I've now inherited SerilUSB from Stream

However peek() and flush() don't do anything at the moment

I'll need to come back and fix the later today if I have time

But things like SerialUSB.find() now work ;-)
So, I wrote this snippet to test:
Code: [Select]
// by mrburnette to test Maple Mini SerialUSB.read and .available functions
// Sketch uses 12,072 bytes (11%) of program storage space. Maximum is 108,000 bytes.
// Program:    14,288 bytes (.text + .data + .bootloader)   Data: 2584 bytes (.data + .bss + .noinit)
void setup() {
  SerialUSB.begin() ;
  delay(5000) ; // 5 seconds to open console terminal against virtual serial port#
  SerialUSB.print("Type a character, word, or phrase followed by the Enter-key \r\n") ;
}

void loop()
{
  uint8_t temp = SerialUSB.read();
  if(temp != 13)
  {
  SerialUSB.print(temp, BYTE);
  SerialUSB.print(" = ASCII code:");
  } else {
    SerialUSB.print("  = Carriage Return");
  }

  SerialUSB.println(temp);
  if (! SerialUSB.available())
  {
    SerialUSB.println() ;
    SerialUSB.println("Type a character, word, or phrase followed by the Enter-key \r\n") ;
  }
}


and the sketch produces the desired output:
Code: [Select]
Type a character, word, or phrase followed by the Enter-key
S = ASCII code:83
h = ASCII code:104
e = ASCII code:101
  = ASCII code:32
s = ASCII code:115
e = ASCII code:101
l = ASCII code:108
l = ASCII code:108
s = ASCII code:115
  = ASCII code:32
s = ASCII code:115
e = ASCII code:101
a = ASCII code:97
  = ASCII code:32
s = ASCII code:115
h = ASCII code:104
e = ASCII code:101
l = ASCII code:108
l = ASCII code:108
s = ASCII code:115
  = Carriage Return13

Type a character, word, or phrase followed by the Enter-key



But more complex functions seem to have an issue... do not go and jump on this until after I have a good sleep and revisit tomorrow.  The code dies either in or immediately after:
SerialUSB.readBytes( Inst, 2);
And it is an ugly death... LED just fades in/out very fast.
(Snippet is from my working program for the Nano Serial Calculator (http://www.instructables.com/id/Arduino-Scientific-Calculator/?ALLSTEPS)

Ray

Code: [Select]
#include <Streaming.h>

String Operation;
char* Inst = "X\n";
char* sStack[ ] =
  { "A","a","B","b","C","c" };

void setup() {
  SerialUSB.begin() ;
  delay(5000) ;
}

void loop()
{
  // empty the input buffer
  while( SerialUSB.available())
  {
    uint8_t trash = SerialUSB.read() ;
  }

  SerialUSB << "Loop testing \n \r" ;
  // Only want one character + CR: One of AaBbCc
  SerialUSB.readBytes( Inst, 2);
  // Echo to console ... never get here
  SerialUSB << "Var Inst=" << Inst << "\r\n" ;
  // Assign to a String and trim ... from original program
  Operation = Inst;
  Operation.trim();
  // Echo to console
  SerialUSB << "Var Operation=" << Operation << "\r\n" ;

  // loop through the single character array, print the index
  for ( uint8_t j= 0; j<6; j++ )
  {
    if (Operation == (sStack[j]))
    {
      break;
    }

    SerialUSB << "Found character at index: " << j << "\r\n" ;
  }
}
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 04, 2014, 11:54 am
Hi Ray,

I ran that sketch and I can see what you mean.

I know what that pulsing  / fading is caused by.

If the code encounters and ASSERT(0) it ends up running a function called throb() whose sole purpose if to make the LED flash like that !

Actually, it looks like the code was designed to somehow output a debug message on a serial channel if it gets an ASSERT(0), but it doesn't seem to be able to access the channel, either when operating as a Maple with the Maple bootloader and USB serial etc, or when I have the USB to Serial attached

And I've not debugged quite why this is. I'm tempted to get the LED to flash SOS instead of that "throb" as it would be a bit more obvious whats going on, as initially I though that flash was caused by random code execution.


On another note..

I've uploaded a new version to GitHub, which has Serial.flush() and Serial.peek(), and I've renamed SerialUSB to Serial for Maple and Maple Mini builds, as I can't see any reason to differentiate between Serial and SerialUSB or end users.

The only slight hack is that Serial.begin() for USB based serial does nothing, its just there to comply with the API.



If you can see a reason to continue calling it SerialUSB, let me know and I can change it back.



With the crash in the sketch that uses Streams.

This is crashing for me but not in the same way as I think it is for you, because I have just changed the way that Serial.read() works, and its now non-blocking, rather than blocking. (because I noticed that the functionality of Serial.read() was not that of Arduino 1.0.x - it must have been for Arduino 0022)



But it still crashes as soon as I type a character :-(


At the moment, I'm not sure why this is happening.

As the code in Stream.cpp just seems to read a char and stick it in a buffer

the flashing is normally caused by an ASSERT(0) statment in the code rather than buffer overflow etc, but its possible that it could be a buffer overflow or underflow as well


Let me know if you get to the bottom of it

BTW..

If you look in the code there are at least 2 copies of usb_cdcacm.c  . It looks like when BobC migrated the files from libmaple to the new structure he left some duplicates as the one that is used is in

Arduino_STM32\STM32F1XX\variants\maple_mini\libmaple\usb\stm32f1

Not the one in Arduino_STM32\STM32F1XX\system\.....

I really should remove the one in system but for the moment I've just #if'ed all the code out ;-)
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 04, 2014, 02:15 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
If the code encounters and ASSERT(0) it ends up running a function called throb() whose sole purpose if to make the LED flash like that !
Well, I did read this explanation earlier in the thread but until I was personally presented with the weird flashing, I did not make the connection!  I've seen Leaflabs use of ASSERT, so now I see the results.  But, having the ability to write: Serial << "Hello mate!' ;  is pretty cool and that is working great.  I need to try some of the more advanced features using "?" and see if that passes. I have some 24 hour clock code that uses that feature to keep the display always showing 2 digits between the colons... snippet complements of Rob Tillaart in the comments here: streaming (http://arduiniana.org/libraries/streaming/)

@rogerClark:
Quote
If you can see a reason to continue calling it SerialUSB, let me know and I can change it back.
Roger,
I see no particular reason to maintain the old naming of SerialUSB; which is to say, "Serial" sounds OK to me with in the context of Arduinos such as Mega2560 and Leonardo.  It could be distracting to UNO/Mini users who expect Serial to point to the hardware USART... but, IMO, the Maple and Maple Mini are really not UNO equivalent devices.  Also, hopefully newbies will not be attracted to this core and create mayhem in the support area.  It may be difficult to keep 'em out however with the price of the clones being under $5 in 5 quantity: squarely in the Nano and naked 32U4 ProMicro pricing area.

Thanks again.

Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 04, 2014, 05:38 pm
I've renamed SerialUSB to Serial for Maple and Maple Mini builds, as I can't see any reason to differentiate between Serial and SerialUSB or end users.
if you mean the usb jack built into some boards becomes the default serial i suspect that may not be a good choice. aside from the fact that not all boards have one, theres also the difficulties getting it to work on those that do. imo the stm32 usart1 should be default and mfg bootloader standard way to flash. unlikely those peculiar maple boards will be available much longer but generic stm103 will always be around. or hopefully i misunderstand.

i am a little confused by the "stm to flash - no bootloader" boards entry terminology. its been a while but it did work for me and iirc thought i was using the mfg built-in bootloader.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 04, 2014, 05:50 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Roger:  Downloaded and installed the new GitHub package.

Quote
With the crash in the sketch that uses Streams.

This is crashing for me but not in the same way as I think it is for you, because I have just changed the way that Serial.read() works, and its now non-blocking, rather than blocking. (because I noticed that the functionality of Serial.read() was not that of Arduino 1.0.x - it must have been for Arduino 0022)
Bravo... except, this needs to become an exception (others may exist):
Serial.readBytes(buffer, length) Link (http://arduino.cc/en/Serial/ReadBytes)
Serial.readBytesUntil(character, buffer, length) Link (http://arduino.cc/en/Serial/ReadBytesUntil)

This code:
Code: [Select]
// Binary sketch size: 4,666 bytes (of a 30,720 byte maximum)

#define BAUD 9600
#define timeoutPeriod 2147483647    // Long var... about 25 days

float a;
float b;


void setup()
{
  Serial.begin(BAUD);
  Serial.setTimeout(timeoutPeriod); // default is 1 second
  delay(5000) ;
}

void loop()
{
  Serial.println("Enter first integer: ");
  {
    a = Serial.parseInt();        // new command in 1.0 forward
    Serial.print("a = "); Serial.println(a);
  }

  Serial.println("Enter second integer: ");
  {
       //Side 2
    b = Serial.parseInt();
    Serial.print("b = "); Serial.println(b);
  }
  a = a / b;
  Serial.print( "a/b = "); Serial.println(a);
}


Produces this correct output:
Code: [Select]
Enter first integer:
a = 12.00
Enter second integer:
b = 23.00
a/b = 0.52
Enter first integer:
a = 45.00
Enter second integer:
b = 55.00
a/b = 0.82
Enter first integer:
a = 355.00
Enter second integer:
b = 113.00
a/b = 3.14
Enter first integer:


I realize that BAUD does nothing for SerialUSB and I have not investigated the TimeOutPeriod although passing it seems to have no ill effect.


Ray

ADDED:
Another passing test!
About: An Op had a hex string coming in from a device and the time was encoded in that hex string. He knew the positions of the characters:  //"ZD2b102c080c090e05ba0549\0"
Here was my solution.  The Maple Mini works correctly with the strings and substrings.

Code: [Select]
/*
Example by mrburnette (ray) on nano 20140914
Binary sketch size: 5,844 bytes (of a 30,720 byte maximum)
"Public domain example"

http://forum.arduino.cc/index.php?topic=266669
"How do i get index 6+7 and 8+9 from a stream of 24 chars that come from the serial input into the Arduino?
The connected serial device is in idle mode until i send a command to it. When i send "ZD",
it will send a timecode in the format ZD2b102c080c090e05ba0549, where ZD stands for the type of message it returns.
2c represents the minutes and 08 the hours of the the current time (in HEX format). The last 4 chars are a checksum.
There is no CR or NL at the end. I would like to get the minutes and hours as interger values."
*/

#include <Streaming.h>  // get used to this library - it makes serial output easy

char sInput[] = {"ZD2b102c080c090e05ba0549\0"} ;  // this data would come in over the serial connection
String sMM ;          // 0xHH\0 = 5 characters
String sHH ;          // Type String allows for concatenation and substrings
char Mbuf[5] ;        // 5 character user buffer for minutes, same type as serial input
char Hbuf[5] ;        // ditto - this one is for the 2 digit hours (HEX: "0x??\0")
int hours, minutes ;  // This is the final product that we are desiring

void setup(void)
{
  Serial.begin(9600);
  delay(5000);
  Serial << "Beginning Example Run...\r\n" ;
  Serial << "Original String: " << sInput << "\r\n\r\n" ;
  // 0123456789                  <----- Character count in input array (type char)
  //"ZD2b102c080c090e05ba0549\0" <----- Input stream representation stored in char array sInput[]
  //       mmhh                  <----- HEX values we desire within the stream
  sMM += "0x" ; sMM += sInput[6]; sMM += sInput[7]; sMM += '\0' ;  // concatenate individual string elements
  sHH += "0x" ; sHH += sInput[8]; sHH += sInput[9]; sHH += '\0' ;  // ditto
  Serial << "Substrings: " << sHH << ":" << sMM << "\r\n\r\n" ;    // show it on term
  sMM.toCharArray( Mbuf, 5 ) ;            // <----- convert String to Char Array
  sHH.toCharArray( Hbuf, 5 ) ;            //        ditto
  hours  = (int)strtol(Hbuf, NULL, 16);   // <----- cast to (int) because strtol returns long
  minutes= (int)strtol(Mbuf, NULL, 16);   //        ditto
  Serial << "Hours: " << hours << "  Minutes: " << minutes << "\r \n";  // show it on term
 
  Serial << "\r\n *****End of run*****\r\n" ;
  Serial.end();
}

void loop( void ) {}


Console Output:
Code: [Select]

Original String: ZD2b102c080c090e05ba0549

            Hours: 8  Minutes: 44


Roger:  This Maple is beginning to get useful thanks to your effort.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 04, 2014, 05:59 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

...
imo the stm32 usart1 should be default and mfg bootloader standard way to flash
...
This simply is not how the Arduino Leonardo boards function (closest board to Maple):
Arduino Serial (http://arduino.cc/en/reference/serial)

Quote
The Arduino Leonardo board uses Serial1 to communicate via TTL (5V) serial on pins 0 (RX) and 1 (TX). Serial is reserved for USB CDC communication.
So, essentially, boards with more than one serial port or a USB virtual port use Serial to represent the USB.  Serial1, Serial2, Serial3 are all physical USART.  As the UNO has a separate uC for the USB, it really is not in the same category since Serial1 is sacrificed to connect the two uC and is therefore a pseudonym for Serial.


Ray

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 04, 2014, 06:37 pm
i must admit to being even more confused atm. i have a very good understanding of uno/promini port setups. they simply have an avr uart for flashing and for serial libraries. whether this talks to an 8250 type pc port, an external ftdi usb/serial adapter, or a separate onboard 32u usb/serial converter to me appears irrelevant regarding libraries and ide.

having no experience im less familiar with leonardo or due and their built in usb hw. so you are saying we should copy those arrangements even though not all these stm32 boards have a usb jack and ignore the problems people will encounter with maple drivers etc? or am i still not getting it?

is there a boards entry that will compile using the stm32 uart1 as default and another entry for using the proprietary maple usb hardware?
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 04, 2014, 07:09 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

...

having no experience im less familiar with leonardo or due and their built in usb hw. so you are saying we should copy those arrangements even though not all these stm32 boards have a usb jack and ignore the problems people will encounter with maple drivers etc? or am i still not getting it?

is there a boards entry that will compile using the stm32 uart1 as default and another entry for using the proprietary maple usb hardware?
What I am discussing is the Maple Mini board and any other STM32F1xx that is using the USB onboard.  The core can be configured to manage the serial numbering based upon the board name (via environmentals).  What roger decides to do, I do not know because he has both the Maple Mini and a non-USB version... he is looking for a compromise situation where the examples will run on Maple/MapleMini/Other.  (The other would be the built-in firmware serial bootloader from STM and uses a different upload utility than DFU.)

Honestly,IMO, most of these issues are non-issues because one can use #define Serial1 Serial


Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 04, 2014, 07:40 pm
yes, we can always #define just about anything. based on the comment about beginners my concern was with defaults rather than customizations. i find it quite nice to have examples work with as little change as possible.

i look at it as lowest common denominator more than compromise. all boards with built in usb jack have a uart1 port but the reverse is not true.

input was requested and thats mine. of course the wonderful thing about open source is if we dont like something we can change it. i hope to use this with "ghetto" stm32f103 boards for a rather large group of engineering students next few years and the less modifications the better. roger has done all the hard work so far and im hoping we make good choices for defaults which is what noobs encounter first.

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 04, 2014, 07:57 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

...
i hope to use this with "ghetto" stm32f103 boards for a rather large group of engineering students next few years and the less modifications the better. roger has done all the hard work so far and im hoping we make good choices for defaults which is what noobs encounter first.
Yes, but you are managing that educational environment.  I really, really do not think that the Forum wishes this to grow into the shady support of the 1284P core.  It is one thing for senior members to post a core but while the forum is Open Source we certainly ( read this as "I") do not want the core tied to Arduino as if it were a supported product.  Young and Old, Smart and less-Smart take note: "This is not an Arduino supported product or development environment - If you do not know what you are doing then DO NOT DO IT."

Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 04, 2014, 08:00 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Roger,

After several successes, a failure which I have not ever seen previously - my first in 4 years of playing around with these Arduino toys... (appears to be in the Standard Template Lib so I think the STM32F1XX will need definition).

ERROR: #error "can't determine endianess"

Code: [Select]
Build options changed, rebuilding all
Using library stlport in folder: D:\Documents\Arduino\libraries\stlport (legacy)

C:\Program Files (x86)\Arduino_158/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_maple_mini -DVECT_TAB_FLASH -DERROR_LED_PORT=GPIOB -DERROR_LED_PIN=1 -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=158 -DARDUINO_STM32F1XX_MAPLE_MINI -DARDUINO_ARCH_STM32F1XX -DMCU_STM32F103CB -mthumb -MD -DSTM32_MEDIUM_DENSITY -DBOOTLOADER_maple -march=armv7-m -D__STM32F1XX__ -ID:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple -ID:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/include -ID:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/stm32f1/include -ID:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/usb/stm32f1 -ID:\Documents\Arduino\hardware\STM32\STM32F1XX\system/libmaple/usb/usb_lib -ID:\Documents\Arduino\hardware\STM32\STM32F1XX\cores\maple -ID:\Documents\Arduino\hardware\STM32\STM32F1XX\variants\maple_mini -ID:\Documents\Arduino\libraries\stlport C:\Users\Ray\AppData\Local\Temp\build5572142531798274906.tmp\Right_Triangle.cpp -o C:\Users\Ray\AppData\Local\Temp\build5572142531798274906.tmp\Right_Triangle.cpp.o
In file included from D:\Documents\Arduino\libraries\stlport/stl/config/features.h:94:0,
                 from D:\Documents\Arduino\libraries\stlport/stl/_cprolog.h:18,
                 from D:\Documents\Arduino\libraries\stlport/math.h:18,
                 from Right_Triangle.ino:7:
D:\Documents\Arduino\libraries\stlport/stl/config/_system.h:196:4: error: #error Unknown platform !!
 #  error Unknown platform !!
    ^
In file included from D:\Documents\Arduino\libraries\stlport/stl/config/_system.h:202:0,
                 from D:\Documents\Arduino\libraries\stlport/stl/config/features.h:94,
                 from D:\Documents\Arduino\libraries\stlport/stl/_cprolog.h:18,
                 from D:\Documents\Arduino\libraries\stlport/math.h:18,
                 from Right_Triangle.ino:7:
D:\Documents\Arduino\libraries\stlport/stl/config/stl_mycomp.h:33:2: error: #error "Your compiler version is not recognized by STLport. Please edit <stlport/stl/config/stl_mycomp.h>"
 #error "Your compiler version is not recognized by STLport. Please edit <stlport/stl/config/stl_mycomp.h>"
  ^
In file included from D:\Documents\Arduino\libraries\stlport/stl/_cprolog.h:18:0,
                 from D:\Documents\Arduino\libraries\stlport/math.h:18,
                 from Right_Triangle.ino:7:
D:\Documents\Arduino\libraries\stlport/stl/config/features.h:175:6: error: #error "can't determine endianess"
 #    error "can't determine endianess"
      ^
Error compiling.


Offending Code:

Code: [Select]
/* Right Triangle - User Interactive via Serial Terminal
   M. Ray Burnette 20130125
   Arduino Nano 328P target processor
   Binary sketch size: 5,202 bytes (of a 30,720 byte maximum)
*/

#include "math.h"               // include the Math Library

#define BAUD 9600
#define timeoutPeriod 2147483647    // Long var... about 25 days

float a;
float b;
float h;
char junk = ' ';

void setup()                    // run once, when the sketch starts
{
  Serial.begin(BAUD);           // set up Serial library at 9600 bps
  Serial.setTimeout(timeoutPeriod); // default is 1 second

  Serial.println("Let's calculate a hypotenuse, h");
  Serial.println("               /|");
  Serial.println("             /  |");
  Serial.println("           /    |");
  Serial.println("      h  /      |");
  Serial.println("       /       b|");
  Serial.println("     /          |");
  Serial.println("   /            |");
  Serial.println(" /________a_____|");
  Serial.println("");
  Serial.println("");
 
}

void loop()
{
  Serial.println("Enter value for leg 'a', Press ENTER");
  while (Serial.available() == 0) ;  // Wait here until input buffer has a character
  {
      //Side 1
    a = Serial.parseFloat();        // new command in 1.0 forward
    Serial.print("a = "); Serial.println(a, DEC);

    while (Serial.available() > 0)  // .parseFloat() can leave non-numeric characters
    { junk = Serial.read() ; }      // clear the keyboard buffer
  }

  Serial.println("Enter value for leg 'b', Press ENTER");
  while (Serial.available() == 0) ;
  {
      //Side 2
    b = Serial.parseFloat();
    Serial.print("b = "); Serial.println(b, DEC);
    while (Serial.available() > 0)
    { junk = Serial.read() ; }

    h = sqrt ( a*a + b*b );

    Serial.print("hypotenuse = ");
    Serial.println(h, DEC); Serial.println();
  }
}


More Offending Code (STL error) for Mini that works on Nano 328:

Code: [Select]
// Nano: Binary sketch size: 2,170 bytes (of a 30,720 byte maximum)
// Parse array of characters

#include <string.h>

char *record = "name:bob";
char *p, *i;

void setup() {

   Serial.begin(9600);
   delay(5000);
   Serial.println("Starting..");
   
    //  First strtok iteration
    p = strtok_r(record,":",&i);
    Serial.print(p);
    Serial.print(" = ");

    //  Second strtok iteration
    p = strtok_r(NULL,":",&i);
    Serial.print(p);
    Serial.println("");

}

void loop () {
}



Defining a template class within the Sketch does work, however:

Code: [Select]
// Tested on Nano and on Maple Mini
// Adapted my RayBurnette from Modified for Arduino from: http://www.cplusplus.com/reference/cstdlib/strtol/
template<class T> inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; }

  char szNumbers[] = "2001 60c0c0 -1101110100110100100000 0x6fffff";
  char * pEnd;
  long int li1, li2, li3, li4;

void setup() {
  /* strtol example */
  Serial.begin(9600);
  delay(5000) ;  // for Maple Mini to allow console opening
  li1 = strtol (szNumbers,&pEnd,10);  // BASE 10
  li2 = strtol (pEnd,&pEnd,16);       // HEX
  li3 = strtol (pEnd,&pEnd,2);        // Binary
  li4 = strtol (pEnd,NULL,0);         // Integer constant with prefixed base Octal or Hex
  //Serial.print ("The decimal equivalents are: %ld, %ld, %ld and %ld.\n", li1, li2, li3, li4);
  Serial << "The decimal equivalents are: " << li1 << " " << li2 << " " << li3 << " " << li4;
  //return 0;
}



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


Console Output:

Code: [Select]
The decimal equivalents are: 2001 6340800 -3624224 7340031

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 04, 2014, 08:16 pm
"I") do not want the core tied to Arduino as if it were a supported product.  Young and Old, Smart and less-Smart take note: "This is not an Arduino supported product or development environment - If you do not know what you are doing then DO NOT DO IT."
we should agree to disagree there. imo doing something is the best way to learn when you dont know what you are doing. one foot in front of the other theory.

and for me the closer these "experiments" get to the official package the better. im hoping regular arduino which they already know up and down can act as a gateway drug to the hard stuff (arm).

it would be nice if one of the board entries stays uart1 as default if that isnt already the plan. i havent tried the latest zip but that last on the list of boards entries did work for me before and it was wonderful.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 04, 2014, 09:12 pm
Ray and John,

I think I have not explained things very well regarding the Serial connection, and also perhaps I need to rename the "no bootloader" board type.

What I meant with No bootloader, was boards that don't use the Maple Bootloader, but I guess this is confusing as the device must have its own built in bootloader otherwise it wouldn't be possible to upload via USB to serial.

It's easy to change this name in board.txt. Perhaps the non Maple boards should be called Generic STM32F103xxx.

Actually I need to make some new board types as I have at least 3 different STM32F103 devices, one of which is a "High Density", STM32F103RCT which has more ram more rom and extra outputs, it has DAC channels.
But the main difference is the increased ram and rom which I should really define correctly in a new board definition, when I get time.



Anyway, back to Serial

What physical device is used as Serial, depends on which board type you select.

If you select any of the Maple board types.

Serial. maps to the on board USB connector
Serial1 maps to Hardware Serial 1
Serial2 maps to Hardware Serial 2 etc


If you select a non Maple board type, e.g the one called No Bootloader,
Serial maps to Hardware Serial 1
Serial1 maps to Hardware Serial 2


The mapping I have done with the boards, depending on which type you select, I felt was consistent with what the Arduino team have already done.

E.g. For Non Maple generic boards, the mapping is effectively like a Mega2560, which has multiple Hardware Serial channels, e.g 1,2,3 but these are mapped to the names Serial, Serial1,Serial2

When you select a Maple board, it follows what the Leonardo board does, I.e the Leonardo uses the ATMega 32U4 device, which like the STM32 has built in support for USB, so that the hardware RX and TX lines are not connected to anything.
On a Leonardo,   "Serial" is like SerialUSB on the Maple boards, hence I renamed SerialUSB on Maple to just be "Serial"


So I don't see any conflict between Maple and non Maple users of the code, because the mapping is different.


PS. I'm not doing this with #define, as I think its likely to screw things up, as the word Serial may occur elsewhere in the code, and I'm not entirely sure how the pre processor would mangle the code if I did it that way.

There are a load of #ifdef's in the code which are used to control the mapping of Serial, Serial1 etc


I think the only problem with what I have done is that the old Maple examples, that have SerialUSB in them, wont compile. But I think that its a small price to pay for allowing  all other non maple code relating to Serial, to compile.


I hope this has cleared up the confusion, and I'm happy to make changes e.g add a new board type,mid the mapping is not to someone's liking ;-)
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 04, 2014, 09:27 pm
Ray

Thanks for trying various types of code

Re

Quote
appears to be in the Standard Template Lib so I think the STM32F1XX will need definition
Umm...

Ok. I will take a look.

I'm not sure where that file is located. If its in the IDE this will be a problem.

I think we are breaking new ground here, because I looked at what the Teensy does and the ChipKit 32, and neither use Arduino 1.5.x, as far as I can tell, they both overwrite core Arduino files in the 1.0 IDE to do what is needed.

I will take a look and get back to you on this one ;-)
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 04, 2014, 09:55 pm
Ray,

Where did you get the first bit of offending code ?


Edit.

I see you wrote it ;-)

Quote
/* Right Triangle - User Interactive via Serial Terminal
   M. Ray Burnette 20130125
   Arduino Nano 328P target processor
   Binary sketch size: 5,202 bytes (of a 30,720 byte maximum)
*/
Is this is test ;-) (

This bit in particular looks like one of those tests to see how well you know C

(LOL)



Code: [Select]

while (Serial.available() == 0) ;  // Wait here until input buffer has a character
  {
      //Side 1
    a = Serial.parseFloat();        // new command in 1.0 forward
    Serial.print("a = "); Serial.println(a, DEC);

    while (Serial.available() > 0)  // .parseFloat() can leave non-numeric characters
    { junk = Serial.read() ; }      // clear the keyboard buffer
  }




i.e I'm not sure why the code is in braces below the while as the while as a semi colon after it, hence the code in brackets is not anything to do with while, it just visually looks like it should be


Edit.

Ray

I think the issue with the code is not the strange way the code looks.

I'm fairly sure this, believe it or not.... is a bug in my implementation of Serial.peek()

i.e Stream:parseFloat() seems to use Serial.peek()  

I have tested Serial.peek() but for some reason, it seems to not return straight away.


There was already a low level peek() function in the usb serial file ( usb_cdcacm.c )

Code: [Select]
* Nonblocking byte lookahead.
 *
 * Looks at unread bytes without marking them as read. */
uint32 usb_cdcacm_peek(uint8* buf, uint32 len) {
    int i;

    if (len > n_unread_bytes) {
        len = n_unread_bytes;
    }

    for (i = 0; i < len; i++) {
        buf[i] = vcomBufferRx[i + rx_offset];
    }

    return len;
}


which gets passed a buffer and returns the number of bytes read.

So I call it like this from usb_serial.cpp



Code: [Select]
int USBSerial::peek(void)
{
    uint8 b;
 if (usb_cdcacm_peek(&b, 1)==1)
 {
 return b;
 }
 else
 {
 return -1;
 }
}


passing in a single character as the buffer and requesting 1 char as the lengh

If it returns 1, i.e there is a character to peek at, it returns that char, otherwise it returns 1

However...

I have seen something very odd happening.

where entering more charaters causes temporary freezes


I will post exmaple code in a while





Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: ChilliTronix on Dec 04, 2014, 09:58 pm
I think the only problem with what I have done is that the old Maple examples, that have SerialUSB in them, wont compile. But I think that its a small price to pay for allowing  all other non maple code relating to Serial, to compile.


I think it likely that people will be trying Arduino rather than Maple examples, so I am sure that will not be an issue whereas it would be the other way around.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 04, 2014, 10:05 pm
I think it likely that people will be trying Arduino rather than Maple examples, so I am sure that will not be an issue whereas it would be the other way around.
Thanks.

My thoughts exactly ;-)
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 04, 2014, 11:04 pm
Ray,

There is definitely a big in peek() somewhere which seems to crash the low level USB Serial stuff, and hangs the PC device communicating with the USB Serial driver. :-(


i.e this code works OK for the first bit of data that you send, but the second thing you send, seems to hang the USB device.

Code: [Select]
void setup() {
  // put your setup code here, to run once:
Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
Serial.println(Serial.peek());
delay(500);
}



It also looks like I broke the non Maple serial stuff when I changed SerialUSB to Serial :-(

I better fix that first



Edit.


Ok. Fixed that issue.

I was relying on a #define BOARD_HAVE_SERIALUSB  but what I didnt realise is that this doesn't come from the boards.txt file, its gets defined in boards.h and as far as I can tell its defined all the time for "Maple" boards regardless of whether I want to use the Maple bootloader or not

So I've made a bit of a hacky change to resolve this.

In the longer term, the #defines need to be cleaned up a bit so that we could use a "Maple" board but withhout a Maple Bootloader (but thats just semantics)

The new version is in GitHub.


Also....

Ray.

I have multiple copies of Arduino installed, and I can't get your example code (hypotenuse) to work in 1.5.8 or 1.5.7 even using a Duemilanove board.

But when I switch back to 1.0.5 your code works fine.

So there are multiple problems

1. Perhaps Serial.parseFloat() is broken and no one in the Arduino team has noticed ??
2. I have a problem with Serial.peek() for the USB Serial device. Well when I say I have a problem, its a bit strange that the USB stack seems to crash (unless all the code has completely crashed) I wonder if this is a bug in the bootloader Serial code, as I can't really see what I'm going wrong in my peek() code - but its totally possible that I have screwed up somehow



Anyway, when you get chance can you test your hypoteneuse code on a traditional Arduino board and see if it works for you on 1.5.x ?

If it doesn't, then perhaps a bug submission is required (but I'm not sure where bugs for this are reported )

Thanks

Roger



Anyway. I better get on with my real work now (day job ;-)

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 04, 2014, 11:15 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
I hope this has cleared up the confusion, and I'm happy to make changes e.g add a new board type,mid the mapping is not to someone's liking ;-)
Agree.... Parallel of my answer in #632, but you explained it better (longer)

Quote
Ray,

Where did you get the first bit of offending code ?

This bit in particular looks like one of those tests to see how well you know C
I wrote it for an Instructable... Which was intended to educate. (I once taught adults)

Quote
think the issue with the code is not the strange way the code looks.
I know it looks funny... Alas, not all working code is pretty.

Quote
I have seen something very odd happening.
An Ah-Ha moment?   This is when I miss a full development system with chip-level debugging and trace.

Quote
Quote from: ChilliTronix on Today at 08:58 pm
I think it likely that people will be trying Arduino rather than Maple examples, so I am sure that will not be an issue whereas it would be the other way around.
A few pages back, on Monday, I went through each Maple supplied example to ensure it compiled and made a couple of changes and attached a ZIP.  When everything is the way Roger wants it, I can refresh that document.

Quote
It also looks like I broke the non Maple serial stuff when I changed SerialUSB to Serial :-(

I better fix that first
Things are deeply inner-twined.  Seriously, SerialUSB is an OK name from my standing... Every board has some quirks... Anyone working with Leonardo knows that.

Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 05, 2014, 12:09 am
If you select a non Maple board type, e.g the one called No Bootloader,
Serial maps to Hardware Serial 1
great. im glad thats still the case. looks like rays board is the usb version and being lucky to get it running w/o much trouble is inclined in that direction. glad to hear youre still accommodating both types.

personally i dont see anything worth changing atm. maybe remove the "no bootloader" phrase as you suggested. it did throw me for a loop but i tried them all and that one worked. simple "stm32f103c8" and "stm32f103rb" or your "stm32 medium density" and "stm32 high density" for those entries sounds good to me. if this is all we have to discuss thats probably a sign things are going well.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: ChilliTronix on Dec 05, 2014, 01:50 am
A few pages back, on Monday, I went through each Maple supplied example to ensure it compiled and made a couple of changes and attached a ZIP.  When everything is the way Roger wants it, I can refresh that document.

Well done for that Ray, but I was thinking of the Maple ones that are on their site. It would be useful to have somewhere to host all this work....A wiki etc.

I may be in a position to look at volunteering some space in a month or twos time.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 05, 2014, 02:05 am
Ray
Quote
This is when I miss a full development system with chip-level debugging and trace.
I have ordered an STLink (clone) usb thing, I'm not sure if it will help but you never know

The JTag interface I ordered from eBay, never turned up. I got a refund, and ordered the STLink as it was cheap and is designed to work with STM devices, but I'm not sure if there is any way to debug using it

I noticed that there is code that the LeafLabs guys wrote that implies that it looks for a debugging adaptor, but I've not had time to investigate quite how that is done.

I suppose it may be possible to use GDB somehow, but I've never used it before - well I looked at it a few years ago, but it seemed hard to use as it didnt have any form of GUI :-(  but I'm probably years out of date


Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: HiddenPilot on Dec 05, 2014, 06:38 am
I apologize for my bad English. I have a few additions to the bob's / clark's "maple-asp/Arduino_STM32"

First: If you use the "LeafLabs Maple Mini Rev 2 to RAM", it causes a compile error: "sketch_dec05a.cpp: 1: 0: error: target CPU does not support ARM mode #line 1" sketch_dec05a.ino ".

I think, this is caused by a bug in the file boards.txt.

Code: [Select]

maple_miniRAM.name = LeafLabs Maple Mini Rev 2 to RAM

mapleRAM.upload.tool = maple_upload
mapleRAM.upload.protocol = maple_dfu
mapleRAM.upload.maximum_size = 17000
mapleRAM.upload.use_1200bps_touch = false
mapleRAM.upload.file_type = bin
mapleRAM.upload.ram.maximum_size = 17000
mapleRAM.upload.flash.maximum_size = 108000
mapleRAM.upload.usbID = 1EAF: 0003
mapleRAM.upload.altID = 0
mapleRAM.upload.auto_reset = true

maple_miniRAM.build.mcu = cortex-m3
maple_miniRAM.build.f_cpu = 72000000L
maple_miniRAM.build.core = maple
mapleRAM.build.extra_flags = -DMCU_STM32F103CB -mthumb -MD -DSTM32_MEDIUM_DENSITY -DBOOTLOADER_maple -march = armv7-m
mapleRAM.build.ldscript = ld / ram.ld
mapleRAM.build.variant = maple_mini
mapleRAM.build.variant_system_lib = libmaple.a
mapleRAM.build.vect = VECT_TAB_RAM
mapleRAM.build.density = STM32_MEDIUM_DENSITY
mapleRAM.build.error_led_port = GPIOB
mapleRAM.build.error_led_pin = 1


I think it should be replaced by:
Code: [Select]

maple_miniRAM.name = LeafLabs Maple Mini Rev 2 to RAM

maple_miniRAM.upload.tool = maple_upload
maple_miniRAM.upload.protocol = maple_dfu
maple_miniRAM.upload.maximum_size = 17000
maple_miniRAM.upload.use_1200bps_touch = false
maple_miniRAM.upload.file_type = bin
maple_miniRAM.upload.ram.maximum_size = 17000
maple_miniRAM.upload.flash.maximum_size = 108000
maple_miniRAM.upload.usbID = 1EAF: 0003
maple_miniRAM.upload.altID = 0
maple_miniRAM.upload.auto_reset = true

maple_miniRAM.build.mcu = cortex-m3
maple_miniRAM.build.f_cpu = 72000000L
maple_miniRAM.build.core = maple
maple_miniRAM.build.extra_flags = -DMCU_STM32F103CB -mthumb -MD -DSTM32_MEDIUM_DENSITY -DBOOTLOADER_maple -march = armv7-m
maple_miniRAM.build.ldscript = ld / ram.ld
maple_miniRAM.build.variant = maple_mini
maple_miniRAM.build.variant_system_lib = libmaple.a
maple_miniRAM.build.vect = VECT_TAB_RAM
maple_miniRAM.build.density = STM32_MEDIUM_DENSITY
maple_miniRAM.build.error_led_port = GPIOB
maple_miniRAM.build.error_led_pin = 1


With this correction, I got a normal compilation code to be loaded to RAM
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: HiddenPilot on Dec 05, 2014, 06:43 am
Second:
I tried to port the library ST7735R from teensy to "Arduino_STM32".
http://pjrc.com/teensy/td_libs_ST7735.html
https://github.com/adafruit/Adafruit-GFX-Library

For testing, I used the example "graphicstest_highspeed"
I replaced in it "Serial." to "SerialUSB." and "SerialUSB.begin (9600)" on "SerialUSB.begin ()"

Then I got the error:
"cpp: 21: 26: fatal error: pins_arduino.h: No such file or directory
#include "pins_arduino.h"

I created the 2 files
hardware \ Arduino_STM32 \ STM32F1XX \ variants \ maple_mini \ pins_arduino.h
and
hardware \ Arduino_STM32 \ STM32F1XX \ variants \ maple \ pins_arduino.h
with the code:
Code: [Select]
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include "board/board.h"

#endif

Then I got the error:
cpp: 22: 28: fatal error: wiring_private.h: No such file or directory
#include "wiring_private.h"

I created the file
hardware \ Arduino_STM32 \ STM32F1XX \ cores \ maple \ wiring_private.h
with the code:
Code: [Select]
#ifndef WiringPrivate_h
#define WiringPrivate_h

#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>

#ifdef __cplusplus
extern "C" {
#endif

// Includes Atmel CMSIS
// # include <chip.h>

#include "wirish.h"

#ifdef __cplusplus
} // Extern "C"

#include "HardwareSerial.h"

#endif

#endif

Then I got a few errors related to "Adafruit_ST7735.cpp". But I will tell about it later or just give ported library "Adafruit_ST7735" for "Arduino_STM32" and "libmaple"
I guess would be useful to append the above files (wiring_private.h, pins_arduino.h) into "Arduino_STM32".

Also, I am grateful to Bob and Clark for their work
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 05, 2014, 11:28 am
@HiddenPilot

Welcome to the world of STM32 on the Arduino.


Thanks for the bug report and fix for Maple-mini to Ram. I had not tested this original code written by BobC, but I can see what you mean, as Bob had forgotten to update most of the lines

I have now updated boards.txt and committed to GitHub



Re: SerialUSB

I have changed the code yesterday. Please download the latest version from GitHub.


SerialUSB is now just called Serial, so there is no need to change any code  ;-)

Re: Missing file pins_arduino.h

I've created empty files for the missing files however the main problem this library is not going to work is that it has hardware specific defines in the header

e.g.

Code: [Select]

#if defined(__AVR__) || defined(CORE_TEENSY)
volatile uint8_t *dataport, *clkport, *csport, *rsport;
  uint8_t  _cs, _rs, _rst, _sid, _sclk,
           datapinmask, clkpinmask, cspinmask, rspinmask,
           colstart, rowstart; // some displays need this changed
#endif //  #ifdef __AVR__

#if defined(__SAM3X8E__)
  Pio *dataport, *clkport, *csport, *rsport;
  uint32_t  _cs, _rs, _rst, _sid, _sclk,
            datapinmask, clkpinmask, cspinmask, rspinmask,
            colstart, rowstart; // some displays need this changed
#endif //  #if defined(__SAM3X8E__)



So.

The first thing that you need to do is add a new block

e.g. like this

Code: [Select]
#if defined(__STM32F1XX__)
volatile uint8_t *dataport, *clkport, *csport, *rsport;
  uint8_t  _cs, _rs, _rst, _sid, _sclk,
           datapinmask, clkpinmask, cspinmask, rspinmask,
           colstart, rowstart; // some displays need this changed
#endif //  #if defined(__STM32F1XX__) 


However this still gives some errors because there are some core functions missing, which have not been added for this STM32 port

i.e the missing functions are

digitalPinToBitMask()

SPI.setBitOrder()

SPI.setDataMode()

i.e 2 new functions for SPI (which were not in the original LeafLabs HardwareSPI and also
digitalPinToBitMask()

The problem with digitalPinToBitMask presumes is that its generally used for direct access to the GPIO, by specific libraries, however I'm not sure whether bits needs to be masked when using the STM32 GPIO.

If you look at libraries that use this, for example AdaFruit_ST7725 they use it like this
Code: [Select]

  cspinmask = digitalPinToBitMask(_cs);
  rspinmask = digitalPinToBitMask(_rs);


However there is platform specific code to use these pins

If you look at the version of the library you downloaded for the Teensy

There are big blocks of Teensy specific code (MK20DX128 is the Teensy processor)

e.g.


Code: [Select]
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
if (_sid == 0) _sid = 11;
if (_sclk == 0) _sclk = 13;
if ( spi_pin_is_cs(_cs) && spi_pin_is_cs(_rs)
&& (_sid == 7 || _sid == 11)
&& (_sclk == 13 || _sclk == 14)
&& !(_cs ==  2 && _rs == 10) && !(_rs ==  2 && _cs == 10)
&& !(_cs ==  6 && _rs ==  9) && !(_rs ==  6 && _cs ==  9)
&& !(_cs == 20 && _rs == 23) && !(_rs == 20 && _cs == 23)
&& !(_cs == 21 && _rs == 22) && !(_rs == 21 && _cs == 22) ) {
hwSPI = true;
if (_sclk == 13) {
CORE_PIN13_CONFIG = PORT_PCR_MUX(2) | PORT_PCR_DSE;
SPCR.setSCK(13);
} else {
CORE_PIN14_CONFIG = PORT_PCR_MUX(2);
SPCR.setSCK(14);
}
if (_sid == 11) {
CORE_PIN11_CONFIG = PORT_PCR_MUX(2);
SPCR.setMOSI(11);
} else {
CORE_PIN7_CONFIG = PORT_PCR_MUX(2);
SPCR.setMOSI(7);
}
ctar = CTAR_12MHz;
pcs_data = spi_configure_cs_pin(_cs);
pcs_command = pcs_data | spi_configure_cs_pin(_rs);
SIM_SCGC6 |= SIM_SCGC6_SPI0;
SPI0.MCR = SPI_MCR_MDIS | SPI_MCR_HALT;
SPI0.CTAR0 = ctar | SPI_CTAR_FMSZ(7);
SPI0.CTAR1 = ctar | SPI_CTAR_FMSZ(15);
SPI0.MCR = SPI_MCR_MSTR | SPI_MCR_PCSIS(0x1F) | SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF;
} else {
hwSPI = false;
cspin = portOutputRegister(digitalPinToPort(_cs));
rspin = portOutputRegister(digitalPinToPort(_rs));
clkpin = portOutputRegister(digitalPinToPort(_sclk));
datapin = portOutputRegister(digitalPinToPort(_sid));
*cspin = 1;
*rspin = 0;
*clkpin = 0;
*datapin = 0;
pinMode(_cs, OUTPUT);
pinMode(_rs, OUTPUT);
pinMode(_sclk, OUTPUT);
pinMode(_sid, OUTPUT);
}

#endif




I don't know how the GPIO access on the MK20DX128 compares with the GPIO on the STM32, because although they are both ARM based processors, AFIK (WestFW knows better than me), the way that the GPIO is controlled is often completely different for each processor.

Hence, if you really want to run this display on the STM32, I suspect you would probably be better off getting the original version from GitHub here https://github.com/adafruit/Adafruit-ST7735-Library

And then modifying it to work with the STM32


e.g. initially, just used digitalWrite instead of these code like

Code: [Select]
  *rsport |=  rspinmask;
  *csport &= ~cspinmask;


Although direct access to the hardware is much faster than using digitalWrite, the problem is that its not cross platform, and you end up with code full of #defines :-( and each new processor type has to write architecture specific code.


Anyway, if you want to investigate adding

SPI.setBitOrder()

SPI.setDataMode()



setBitOrder should be fairly simple to implement, as the code already sets this up from the Settings class.

setDataMode should be easy to implement as well, as its also obvious where it is in the code.

However as both of these are in the Settings class, some though may be needed to make sure the setting is retained



I am working on some other issues with STM32 at the moment, specifically why Serial.peek() crashes on the second set of data, but after I have fixed that. I can probably look at the SPI stuff




Cheers

Roger







Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 05, 2014, 01:38 pm
The JTag interface I ordered from eBay, never turned up.
they did you a favor by not shipping. there is no point to jtag if swd is available. i have both now and can tell you stlink/swd is the way to go. jtag is an obsolete protocol replaced some time ago by swd which is faster and only needs 1/10th as many wires (2 vs 20).

gdb client/server protocol is buried deep so not the real issue which is the shell. ive been playing with oocd and it does a great job for tracing and dumping. for real progress you need an ide like one of the eclipse based ones. unfortunately there is nothing like that for arduino which is probably its biggest drawback.

so its either switch to another set of tools or stumble along debugging arduino in assembly.

btw as usual i vote for keeping as much of this project in one place as possible. as hard as it is to believe those starting out dont really get a big kick out of jumping around the net to find stuff. imo its the biggest impediment to getting something like this to critical mass. already scattered across 5 different sites. it would be a shame if this amazing accomplishment dies in the bud.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 05, 2014, 01:53 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Code: [Select]
[quote author=HiddenPilot link=msg=1988747 date=1417758182]
Second:
I tried to port the library ST7735R from teensy to "Arduino_STM32".
http://pjrc.com/teensy/td_libs_ST7735.html
https://github.com/adafruit/Adafruit-GFX-Library




I slaved off the work of several when I ported the ILI9341 to the ARM M0+ of the PSoC 4200
ILI9341 TFT 240x320 on PSoC 4200 (http://www.hackster.io/rayburne/psoc-4-using-the-color-glcd-ili9341)
I finally just refactored all the library code because it was simply too convoluted with #IF everywhere to support both ARM and AVR.  After combining and simplifying the host of support files, I got a decent (but specific) implementation.

I have not even considered SPI on the ILI9341 yet because other than an SPI loopback, I have not gone deeply enough into testing.  Anyway, there are comments in my the graphic files in the PSoC code that may be useful for anyone wanting to utilize that particular display.  Just to note, however, the PSoC 4200 is ARM @48MHz and the compiler utilizes newlib as well as the GCC compiler.  The development environment is free but has a large learning curve - but very well done.


Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 05, 2014, 04:00 pm
ray, ive been curious about your avatar photo ever since starting here. wax museum statue? halloween costume? or are you really that good looking?

one thing for sure, its catchy and real easy to recognize your posts.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 05, 2014, 04:53 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

ray, ive been curious about your avatar photo ever since starting here. wax museum statue? halloween costume? or are you really that good looking?

one thing for sure, its catchy and real easy to recognize your posts.
hehehehe ;D  At least you know you can jump over those wordy posts.  I used to be a consultant, got paid by the word :smiley-mr-green:

Full credit to this artist: Credit Caveman (http://althouse.blogspot.com/2008/12/howdy-doody-caveman.html)
Me in a selfie: Ol' Ray (http://www.hackster.io/rayburne)
(My friend who runs the site said the caveman photo may run folks away!)

I started using that avatar long time ago back in the laser forums when I was doing research into laser power and eventually published an article on same.  H.E.A.T. (http://www.instructables.com/id/LASER-HEAT/)
Kind of make me look a bit like a cousin of Harry (from Harry and the Hendersons).

Ray
Title: Maple Mini with Nokia B/W GLCD 5110 (84x48)
Post by: mrburnette on Dec 05, 2014, 05:10 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Nokia on Maple Mini.
Disclosure: the graphic routines have evolved over the years that I have used them and I seem to remember that the original came from some Chinese ZIP download but somewhere over time I have misplaced the original source/author - my apologies to same.  I remember Ladyada also doing work on the Nokia... anyway, I am not the original author.  Update 20141206: The following should also have credit: Andy Gock & Alejandro Méndez A. (Twistx77)
References: Here (http://s.agock.com/glcd-documentation/) and here (http://www.tutoelectro.com)

Here is the main sketch for the library-less Nokia GLCD used with Maple in bit-banged SPI.  The ZIP contains multiple files that MUST all reside in the same sketch directory.  This version uses the Serial port which is USB virtual comm to a terminal or Arduino Monitor running on the PC.  I have tested with the Monitor and the keystrokes all appear on the LCD after the initial "test" screen... that is, press ENTER to start typing.  Change Serial to Serial1, Serial2, etc as required but I have not tested yet.

OK readers, it is time to start having some interactive fun with the STM32F1xx.

Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 05, 2014, 09:11 pm
Hi Ray,

Thanks for the Nokia files. I will try them later. I got around to wiring up one of my spare Nokia displays last week, but hadn't got around to actually connecting it up, or looking at the software compatibility with STM32


Re:libraries for external devices

This looks like its going to be the major issue. So far I have seen 2 libraries that are full of #ifdef's

The primary reason for this appears to be because digitialWrite (and digitalRead etc) are slow.

So the solution in the libs I've looked at, is to effectively to store / cache a reference to the hardware register (memory location), and then directly manipulate that location.

Of course this only works if the low level hardware control works in the same way as the AVR.

The OneWire lib that I looked at a few days ago, had a clever idea of defining platform specific macros to set and reset specific bits.
. There were still a lot of #ifdef's, but at least they were all in the top of one file ( I think the top of the cpp)



Its also interesting to see how other people have tried to address this problem.

PJRC (teensy) seem to have done a lot of work, adding Teensy support to existing libraries, and Paul is now the maintainer of a number of key libraries, e.g. OneWire
But I also noticed that Paul has special versions of libs on the PJRC site for libs he is not the maintainer.

I'm not sure what MicroChip did with their Uno32 etc.

I will need to download their IDE and take a look.


Cross platform support is an age old problem, so I'd have thought that a solution already exists.



I guess as more people start to use different libraries, we'll get a better picture of how best to approach these library issues, but currently fast GPIO access is definitely something that needs to be considered.


Title: POsC 4200
Post by: rogerClark on Dec 05, 2014, 09:45 pm
Ray.

I think I will order some PSoC 4200 boards that you referenced ages ago.

The shipping costs to me appear to be a bit steep, unless I can find a local distributed as its $15 on a $4 board

But I will probably get more than one board.

I will let you know what I end up doing.

Edit.

Cypress dont seem to have a presence in Australia at all :-(
So I think I'm going to need to get the PSoC 4200  boards from HongKong. I could get them from Element14 in Australia, but I'm pretty sure their local shipping charges are more than the FedEx costs from HongKong ! (though I better double check)

Edit. Element14 dont even seem to sell the small POsC 4200 board, they only sell the large $38 one.

Edit 2.

Element 14 do sell the board, I just couldn't find it because their search feature is useless.

However its still cheaper for me to get 4 boards FedEx'ed from Cypresses dealer HK than to get 3 boards from Element14 AU. I suspect that they'd also arrive faster, because FedEx are faster than the local carriers ;-)

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: oric_dan on Dec 05, 2014, 10:01 pm
I haven't been following this 42-page epic of a thread, but in case you STM32 guys have not seen it [and I didn't find it in this thread via search],

http://www.botmag.com/spark-photon-improves-upon-the-core/

This is the new $19 board, the original Core is $39. I like the 128KB of RAM. I don't know if they could be adapted to the Ardunio world. [Roger, can you sign up for maybe 9,999 in pre-sales, and I'll get the other one! Oh sorry, you need pre-order only 3184].

https://www.spark.io/
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 05, 2014, 10:29 pm
@oric_dan

Thanks.

Quite interesting, but I'm not sure if I want to pre-order.

I have some ESP8266's which are $5 and have most of the functionality of this device. Albeit the ESP8266's build process is currently in its infancy, and its unlikely to ever be Arduino compatible because its not ARM and has a very specialised toolchain which appears only to be available for Linux at the moment



However from a commercial product point of view that device is interesting as it claims to have FCC approval, (which I don't think the ESP8266 has at the moment)


Its interesting that they chose not to use the Arduino IDE or even Eclipse.
So I'm downloading their IDE now.

As it stands the Arduino IDE is starting to look quite aged, and I know that the Arduino dev's are looking at implementing loads of changes like intelligent code completion, but in some respects they would probably be better off ditching processing and moving to something else that is more suitable for what the Arduino has now become.

And... I think the key strength of the Arduino platform is the API (aka wiring) as it makes development a huge amount easier than for example using Keil or CooCox for STM32 (which have a pretty steep learning curve)


Edit.

Changed my mind.

Pre-ordered 2.

But 4 months or more is going to be a long wait ;-(
Title: Issues reporting / logging
Post by: rogerClark on Dec 05, 2014, 10:50 pm
Guys,

I'm aware of a number of issues with this port, which I have not had time to address.

So to keep track and also so that people can see what issues are in the current code, I've added some issues to the issues tracking on GitHub

See   https://github.com/rogerclarkmelbourne/Arduino_STM32/issues (https://github.com/rogerclarkmelbourne/Arduino_STM32/issues)

If you have any more issues and have a GitHub account, please feel free to add them, or just report them to the forum and I'll attempt to add them when I get chance.



Please note however ....

Before you post an issue, please check that the code in question, still works on AVR hardware under IDE 1.5.8, as it appears that some things no longer work on IDE 1.5.8 even on a Uno

e.g.
Ray's "Hypotenuse" calculator doesn't seem to run on a Uno under IDE 1.5.8, which I think may be an issue with Serial.parse()

And I know other people have reported some other issues with 1.5.8 or 1.5.x in general.



Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: oric_dan on Dec 06, 2014, 12:05 am
Roger, in the meantime you could try the current Spark Core, although it costs more. Would be interesting to see how arduino compatible these things might be.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: HiddenPilot on Dec 06, 2014, 12:35 am
@Clark
Code: [Select]
#if defined(__STM32F1XX__)
volatile uint8_t *dataport, *clkport, *csport, *rsport;
  uint8_t  _cs, _rs, _rst, _sid, _sclk,
           datapinmask, clkpinmask, cspinmask, rspinmask,
           colstart, rowstart; // some displays need this changed
#endif //  #if defined(__STM32F1XX__)  

I'm in the same way implemented a this block(before you wrote this message). It's funny:)

If you look at libraries that use this, for example AdaFruit_ST7725 they use it like this
Code: [Select]

  cspinmask = digitalPinToBitMask(_cs);
  rspinmask = digitalPinToBitMask(_rs);

However there is platform specific code to use these pins

e.g. initially, just used digitalWrite instead of these code like
Code: [Select]
 *rsport |=  rspinmask;
  *csport &= ~cspinmask;

Although direct access to the hardware is much faster than using digitalWrite, the problem is that its not cross platform, and you end up with code full of #defines :-( and each new processor type has to write architecture specific code.
Not so long ago, I wrote a small sketch for testing and optimization of working with STM32 "pins". (For HX711)
After  completion of works under optimization of the code, I got a "Soft CLK" speed of around 8000kHz. With "data read" it was around 4000kHz. I believe that this is an excellent result.
Then I wrote a MACRO. And now I have a very fast-acting analogue of cross-platform functions "digitalRead (pin)" and "digitalWrite (pin, val)". I gave them names _digitalRead (pin) and _digitalWrite (pin, val).
For AVR_arduino I already have the same macros. So, to some extent, we have cross-platform compatibility with the speed like "direct access to the hardware"

Code: [Select]
#define GPIO_BRR_BS1   ((uint32)0x00000002) //PB1
#define nop __asm__ __volatile__ ("nop\n\t")
#define Nop __asm__ __volatile__ ("nop\n\t")
#define NOP __asm__ __volatile__ ("nop\n\t")

// Fast bit read
#define dREAD_D32 gpio_read_bit(GPIOB,8)>>8 //(GPIOB->regs->IDR&(1U<<8)>>8)
#define dREAD_D31 gpio_read_bit(GPIOB,12)>>12
#define dREAD_D30 gpio_read_bit(GPIOB,13)>>13
#define dREAD_D29 gpio_read_bit(GPIOB,14)>>14
#define dREAD_D28 gpio_read_bit(GPIOB,15)>>15
#define dREAD_D27 gpio_read_bit(GPIOA,8)>>8
#define dREAD_D26 gpio_read_bit(GPIOA,9)>>9
// &etc

// Fast bit write
#define dWRITE_D33_1 GPIOB->regs->BSRR = 0x0002
#define dWRITE_D33_0 GPIOB->regs->BRR  = 0x0002
#define dWRITE_D32_1 GPIOB->regs->BSRR = 0x0100
#define dWRITE_D32_0 GPIOB->regs->BRR  = 0x0100
#define dWRITE_D31_1 GPIOB->regs->BSRR = 0x1000
#define dWRITE_D31_0 GPIOB->regs->BRR  = 0x1000
#define dWRITE_D30_1 GPIOB->regs->BSRR = 0x2000
#define dWRITE_D30_0 GPIOB->regs->BRR  = 0x2000
// &etc

//+++++++++Token-Pasting++++++++++++++++
//#define _digitalRead(x) dREAD_D##x
#define _D_READ(x) dREAD_D##x
#define _digitalRead(x) _D_READ(x)

#define _D_WRITE(x,hl) dWRITE_D##x##_##hl
#define _digitalWrite(x,hl) _D_WRITE(x,hl)
//---------Token-Parsing----------------

#define CLK_PIN BOARD_LED_PIN //33
#define DATA_PIN BOARD_BUTTON_PIN //32
#define CYCLES 300000


void setup() {
  pinMode(BOARD_LED_PIN, OUTPUT);
  pinMode(BOARD_BUTTON_PIN, INPUT);
  pinMode(3, INPUT);
  pinMode(12, INPUT);
  pinMode(14, INPUT);
  pinMode(1, INPUT);
  Serial.begin();
}

void loop() {
  static uint32 startT;
  uint32 i,j,k;
  uint32 dur;
  j=0; startT = micros();
  for (k=0; k<CYCLES; k++){
  i=0;
    do{
//      GPIOB_BASE->BSRR = GPIO_BRR_BS1;
//      dWRITE_D33_1;
      _digitalWrite(CLK_PIN,0);
      i++;

      j<<=1;
//      j+= (GPIOB_BASE->IDR&(1<<8)) !=0;
//      j+= (GPIOB->regs->IDR&(1U<<8)>>8);
//      j += gpio_read_bit(GPIOB,8)>>8;
      j += _digitalRead(DATA_PIN);    

//      GPIOB->regs->BRR = GPIO_BRR_BS1;
      _digitalWrite(CLK_PIN,1);
    } while (i<32);//32-bit read
  }
  dur = micros()-startT;
  delay(100);
  Serial.print("F:");Serial.print(uint64(k*i)*1000/dur);Serial.print("kHz / ");
  Serial.print(72*dur/(k*i));Serial.print(" cycles / ");
  Serial.print("dur: "); Serial.print(dur);Serial.print(" mcs / ");
  Serial.print("j="); Serial.print(j,16);
  Serial.print(" / i*k="); Serial.println(i*k);
  delay(100);
  
}

I think it will be possible to use these macros (with additional header file) when porting ST7735R and ili9341

Code: [Select]
F:7940kHz / 9 cycles / dur: 1612060 mcs / j=0 / i*k=12800000
F:7940kHz / 9 cycles / dur: 1612062 mcs / j=0 / i*k=12800000
F:7940kHz / 9 cycles / dur: 1612062 mcs / j=0 / i*k=12800000
F:7940kHz / 9 cycles / dur: 1612061 mcs / j=0 / i*k=12800000


Code: [Select]
F:4172kHz / 17 cycles / dur: 3068007 mcs / j=0 / i*k=12800000
F:4172kHz / 17 cycles / dur: 3068014 mcs / j=0 / i*k=12800000
F:4172kHz / 17 cycles / dur: 3068012 mcs / j=0 / i*k=12800000
F:4172kHz / 17 cycles / dur: 3068014 mcs / j=0 / i*k=12800000
F:4172kHz / 17 cycles / dur: 3068010 mcs / j=0 / i*k=12800000



Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: HiddenPilot on Dec 06, 2014, 12:44 am
@Ray
I slaved off the work of several when I ported the ILI9341 to the ARM M0+ of the PSoC 4200
ILI9341 TFT 240x320 on PSoC 4200 (http://www.hackster.io/rayburne/psoc-4-using-the-color-glcd-ili9341)
I finally just refactored all the library code because it was simply too convoluted with #IF everywhere to support both ARM and AVR.  After combining and simplifying the host of support files, I got a decent (but specific) implementation.
I'll see your library. Thanks! Screens ili9341 soon deliver me.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 06, 2014, 02:37 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

@RayI'll see your library. Thanks! Screens ili9341 soon deliver me.
You may not be thankful after working with Cypress Creator IDE  :o

But, if you like the $4 PSoC 4200 as much as I, then consider buying one (1) of their Pioneer boards - it uses the 4200 uC but also support a full debut, single-step, and register display.  And the code moves completely to the $4 PSoC prototype board without effort.  Thee OpAmp and multiplexer makes the 4200 great for projects that need to support an analog front-dnd, like a piezo sound sensor of even an analog notch/bandpass filter.

If you have not seen them, Go to last years 100 projects: 100 PSoC 4200 (http://www.element14.com/community/thread/23736/l/100-projects-in-100-days)


Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 06, 2014, 02:49 am
@oric_dan


Quote
in the meantime you could try the current Spark Core, although it costs more.
I guess so, but I've already splashed out for 2 x Photon's and 4 x Cypress PSoC's this morning, and on top of that I have 3 x ESP8266 (ESP-01)'s waiting for me to have time to use them, and another 2 x ESP8266's (ESP-03) on order plus some BLE modules that arrived during the week.

I think I have plenty enough to be going on with ;-)

BTW. I just looked at the firmware for the Photo and the Sparc core and the upload stuff looks equally as dodgy as we currently have.

There seems to be a complicated install process to install DFU -and their site links to a site that is no longer even there, in order to get the DFU driver, and then you have to use some other program to unstall the driver


Quote
3. Device Firmware Upgrade Utilities

Install dfu-util 0.7. Mac users can install dfu-util with Homebrew or Macports, Linux users may find it in their package manager, and everyone can get it from http://dfu-util.gnumonks.org/index.html
4. Zatig

In order for the Core to show up on the dfu list, you need to replace the USB driver with a utility called Zadig. Here is a tutorial on using it. This is only required for Windows users.
dfu-util.gnumonks.org/index.html doesnt seem to exist any more

I have used zadig before for another device, but either way, its not the smoothest of installs

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 06, 2014, 03:25 am
Ray

No worries

It cant be that bad ;-)

I'm downloading the IDE now and I've just found the thread about it that you started http://forum.arduino.cc/index.php?topic=257462.0



Cheers

Roger

PS.

My F4 Discovery board just arrived (on a Saturday - which is unusual as we don't normally get regular post on a Saturday, it must be because of the XMas post )

But I don't get time to try it until later today
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: Mark_Grass on Dec 06, 2014, 06:47 am
This is one of the longest threads I've seen!

I'm frustrated with the Maple mini (using Win 7 64 pro) and the DFU error.  I have 5 of them and they all respond the same way.  After a lot of Google searches that didn't help, I ended up on this thread.
I need the capability of the ARM for a couple of projects that the Arduino can't handle.

questions...
1. USB to Serial TTL......I do that with the pro mini and it works great.  So that will work with the Maple Mini on pins 30,31? Do I need to use the 3.3v or 5v from the "USB to Serial"? I don't want to let the magic smoke out.

2. I'd like to be able to use the native USB to program it.  I've installed the unsigned drivers and tried the link to soundforge for drivers, but nothing has changed.  Same error.   When you say "test mode" are you referring to "safe mode?"

3. Are you using the Arduino 1.5.x IDE to program the Maple Mini?   I've installed the 1.5.8 (have 2 DUEs on order). I've tried to upload to the maple but it doesn't work. Tried both choices for the 32bit boards.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 06, 2014, 07:36 am
Hi Mark,

Welcome ;-)



Quote
I'd like to be able to use the native USB to program it
Have you disabled the Device Driver Signing enforcement?  I don't think there is a way to load the drivers apart form by disabling this requirement

Personally, when I boot, I press F8 a few times and Windows displays a load of boot options, one of which (near the bottom of the list is to disable the device driver signing enforcement)

I have just read an article that says it can be turned off permanently.


http://www.technipages.com/enable-disable-device-driver-signing (http://www.technipages.com/enable-disable-device-driver-signing)

So I've just followed those instructions and I will boot in a minute and see if I can still see the Maple Drivers

Re:

Quote
USB to Serial TTL......I do that with the pro mini and it works great.  So that will work with the Maple Mini on pins 30,31? Do I need to use the 3.3v or 5v from the "USB to Serial"? I don't want to let the magic smoke out.
You need to connect to Pin 25 and 26, rx1 and tx1,  apart from that its the same as programming a pro mini in terms of the connections


I measured the TX voltage from my USB to Serial and its 3.5V, and this seems to do no harm to my board.
Actually I have two completely different USB to Serial modules and they both work OK.

I think the RX and TX pins are 5V tolerant anyway

See http://static.leaflabs.com/pub/leaflabs/maple-docs/latest/hardware/maple-mini.html#master-pin-map


One thing you need to do however if you want to upload via USB to Serial is to pull line Boot1 to GND
I have soldered a 10k resistor to the back of my Maple mini, but initially I just took a wire and connected Boot1 to GND directly.

If you don't do this it won't enter Serial upload mode reliably, because Boot1 is floating and sometimes it will be HIGH on reset and sometimes it will be LOW

Then you need to so the 2 finger shuffle on board (see by blog whttp://www.rogerclark.net/uploading-to-the-maple-mini-via-serial-to-usb/ )

However if you get the device drivers loaded this will not be necessary (unless you want to do it this way)


3.
Quote
Are you using the Arduino 1.5.x IDE to program the Maple Mini?   I've installed the 1.5.8 (have 2 DUEs on order). I've tried to upload to the maple but it doesn't work. Tried both choices for the 32bit boards.
Yes.
I presume you have download and installed the files from my GitHub repo ??

Its explained on my blog and also I've done a YouTube tutorial

https://www.youtube.com/watch?v=-zwGnytGT8M (https://www.youtube.com/watch?v=-zwGnytGT8M)

Please note.

I think some things are broken in 1.5.7 and 1.5.8 even on standard Arduino hardware, I've seen reports about things not compiling and I'm also pretty sure that Serial.parseFloat() doesn't seem to work (though I could be wrong)


Also, although Wire and SPI and Serial and the digital and analog outputs and inputs are mostly working, be aware that support for STM32 is very much at Alpha stage.

I've tried to list the known issues on my GitHub repo, but is quite possible that there are other issues but that people have not tried everything, hence we don't know they are issues  (if you see what I mean)


also BTW
Quote
I need the capability of the ARM for a couple of projects that the Arduino can't handle.
The processor is definitely as fast as a Due for most tasks, however be aware that if you use any maths functions e.g. sin() or sqrt() etc, these return double's not floats on this platform (same as the Due) so if you are using float data types, to store the results, the speed of the processor only appears to be around 1.6 x faster than a Uno.

If you use double instead of float, the speed is 2 x of the Uno. and if you use the float functions e.q sqrtf() the performance is around 4 x faster than a Uno

But this should not be news to you if you have a Due.

Also... Max speed on Wire is around 250khz, as its bit banged (not hardware I2C at the moment)
It should be an easy fix to speed this up even using bit-banged code (as the code is not optimized and uses digitalWrite - which is slow on all Arduino platforms)



But overall, I find these a great little board, and can only see things getting better as more people are involved and if possible can contribute to the code fixes and testing.

Update.


The trick to permanently disable the device driver signing enforcement doesn't seem to work. At least not for me under Window 7 Pro x64

So you will need to press F8 each time you boot, if you want to load the Maple DFU device driver.

( apparently Windows 8.1 is better as this setting can be set permanently)
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: oric_dan on Dec 06, 2014, 08:29 am
Yeah Roger, sounds like you have plenty to play with. Will be interesting to see how the ESP8266 goes. I bought a couple, but not played with as yet.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 06, 2014, 12:21 pm
@westFW (or @mrbrunette)

Could either of you tell me what libraries the IDE links in ?

I've tried to look at the verbose output from the IDE but I can't see anything that looks like stdlib

ie as far as I can tell this is the linker lin

Code: [Select]
C:\Program Files (x86)\Arduino/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-g++ -Os -Wl,--gc-sections -mcpu=cortex-m3 -TC:\Users\rclark\Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\variants\maple_mini/ld/jtag.ld -Wl,-Map,C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp/sketch_dec06a.cpp.map -LC:\Users\rclark\Documents\Arduino\hardware\Arduino_STM32\STM32F1XX\variants\maple_mini/ld -o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp/sketch_dec06a.cpp.elf -LC:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\sketch_dec06a.cpp.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\exc.S.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\isrs.S.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\vector_table.S.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\start.S.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\adc.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\adc_f1.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\bkp_f1.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\dac.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\dma.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\dma_f1.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\exti.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\exti_f1.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\flash.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\fsmc_f1.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\gpio.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\gpio_f1.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\i2c.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\i2c_f1.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\iwdg.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\nvic.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\pwr.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\rcc.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\rcc_f1.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\spi.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\spi_f1.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\systick.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\timer.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\timer_f1.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\usart.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\usart_f1.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\usart_private.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\usb.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\usb_cdcacm.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\usb_reg_map.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\usb_core.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\usb_init.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\usb_mem.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\usb_regs.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\util.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\start_c.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\syscalls.c.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\board.cpp.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\boards.cpp.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp\boards_setup.cpp.o C:\Users\rclark\AppData\Local\Temp\build8138158070187034075.tmp/core.a -Wl,--end-group


but nothing in there looks like a stdlib

The reason I ask, is that I'm trying to compile the Arduino files  under CooCox onto the STM32F4 Discovery, because this allows me to debug the code using the STLink

Actually when my external STLink arrives it will allow me to debug on the Maple etc but its not arrived yet

I've got as far as all the files compiling in CooCox, but I get a link error, which as far as I can tell may be because stdlib is missing

Well, you me the judge, the error is



Code: [Select]
       [cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -g -nostartfiles -Wl,-Map=Arduino1.map -Os -Wl,--gc-sections -LC:\CooCox\CoIDE\configuration\ProgramData\Arduino1 -Wl,-TC:\CooCox\CoIDE\configuration\ProgramData\Arduino1/link.ld -g -o Arduino1.elf ..\obj\usb_cdcacm.o ..\obj\usb_core.o ..\obj\boards.o ..\obj\ext_interrupts.o ..\obj\spi.o ..\obj\adc_f1.o ..\obj\fsmc_f1.o ..\obj\i2c.o ..\obj\flash.o ..\obj\dma_f1.o ..\obj\start_c.o ..\obj\timer.o ..\obj\util.o ..\obj\iwdg.o ..\obj\usart_f1.o ..\obj\start.o ..\obj\usb_regs.o ..\obj\pwm.o ..\obj\dtostrf.o ..\obj\usb_init.o ..\obj\main.o ..\obj\i2c_f1.o ..\obj\usb.o ..\obj\board.o ..\obj\HardwareTimer.o ..\obj\wirish_math.o ..\obj\pwr.o ..\obj\boards_setup.o ..\obj\exti_f1.o ..\obj\wirish_digital.o ..\obj\wirish_digital_f1.o ..\obj\rcc_f1.o ..\obj\gpio.o ..\obj\dac.o ..\obj\HardwareSerial.o ..\obj\Stream.o ..\obj\sketch.o ..\obj\wirish_time.o ..\obj\bkp_f1.o ..\obj\Print.o ..\obj\wirish_shift.o ..\obj\timer_f1.o ..\obj\rcc.o ..\obj\isrs.o ..\obj\syscalls.o ..\obj\wirish_debug.o ..\obj\wirish_analog.o ..\obj\exti.o ..\obj\adc.o ..\obj\usb_reg_map.o ..\obj\exc.o ..\obj\itoa.o ..\obj\nvic.o ..\obj\gpio_f1.o ..\obj\cxxabi-compat.o ..\obj\WString.o ..\obj\systick.o ..\obj\util_hooks.o ..\obj\spi_f1.o ..\obj\usb_mem.o ..\obj\dma.o ..\obj\usart_private.o ..\obj\vector_table.o ..\obj\usart.o
       [cc] ..\obj\HardwareSerial.o:(.rodata._ZTI6Stream[typeinfo for Stream]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
       [cc] ..\obj\HardwareSerial.o:(.rodata+0x38): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
       [cc] ..\obj\Print.o:(.rodata+0x1c): undefined reference to `vtable for __cxxabiv1::__class_type_info'
       [cc] collect2: ld returned 1 exit status


Of course this could be because I'm compiling for cortex M4 instead of M3 but I don't think so.

From what I've researched on the web this is to do with missing libraries e.g. stdlib and it makes sense and I can't see stdlib being linked in for the Arduino or for coocox


Thanks

Roger
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: Mark_Grass on Dec 06, 2014, 03:24 pm
Roger,   Thank you so much for taking the time to type all that info.   I will be sure to check it all out today after my work(wife is a major task master) is finished.   

I have to say that the you are the 2nd gent from Australia that has been a major source of info. for me.  I was working on a project several years ago (before I retired, EEngineer, not a programmer) and a young student (fourwalledcubicle.com) was very helpful and giving of his time; really bright young man. 
Have to finish that stone wall.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 06, 2014, 04:00 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Quote
@westFW (or @mrbrunette)

Could either of you tell me what libraries the IDE links in ?
westFW is way more knowledgeable than I, but the standard libraries (auto linked) will be the "board" core files + the architecture "libraries".  So, on my Win8.1/64-bit it would be:

Code: [Select]
C:\Program Files (x86)\Arduino_158\hardware\arduino\avr\cores\arduino
 and

Code: [Select]
C:\Program Files (x86)\Arduino_158\hardware\arduino\avr\libraries\
 and

Code: [Select]
C:\Program Files (x86)\Arduino_158\hardware\tools\avr\avr\include

On the tools side, the 1.5.8 install provides for two paths:
Code: [Select]
C:\Program Files (x86)\Arduino_158\hardware\tools

On the "architecture" side, 1.5.8 provides two distinct out-of-box paths:
Code: [Select]
C:\Program Files (x86)\Arduino_158\hardware\arduino

For stdlib.h that should be included by every/most core files; that is
...hardware\arduino\avr\core
...hardware\arduino\sam\core

For the physical file used with SAM architecture, it is located here:
Code: [Select]
C:\Program Files (x86)\Arduino_158\hardware\tools\gcc-arm-none-eabi-4.8.3-2014q1\arm-none-eabi\include

For the physical file used with AVR architecture, it is located here:
Code: [Select]
C:\Program Files (x86)\Arduino_158\hardware\tools\avr\avr\include
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 06, 2014, 04:00 pm
I'm frustrated with the Maple mini (using Win 7 64 pro) and the DFU error.  I have 5 of them and they all respond the same way.

USB to Serial TTL......I do that with the pro mini and it works great.  So that will work with the Maple Mini on pins 30,31? Do I need to use the 3.3v or 5v from the "USB to Serial"?
3.3v and tx/rx from a ftdi usb/serial converter on pa9/pa10 works using the last, "no bootloader", board entry in rogers boards list. its the only way myself and a few local engineering students were able to get this to work.

another approach is to use the same serial interface to download hex files created by rogers ide directly using the chip manufacturers "flash demonstrator" utility. a few very basic methods to do this are described on an eevblog site: google "ghetto arm development".

personally im not enthusiastic over the maple usb drivers seeing how many people fail to get it working. imo better to take advantage of the bootloader built into all STM chips which is what that last entry in rogers list does.

hey ray, looks like my first guess was right. museum piece. that link brought back memories. howdy doody was a great hero for me when i was a kid.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 06, 2014, 04:18 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

@john1993:
Quote
personally im not enthusiastic over the maple usb drivers seeing how many people fail to get it working. imo better to take advantage of the bootloader built into all STM chips which is what that last entry in rogers list does.
I think one of the great fallacies associated with an effort such as this port is that the OEM gets blamed for the outdated drivers and associated installation problems.  The truth is, Leaflabs no longer supports the Maple or Maple Mini and from what I can determine, has not since driver-signing was optional in Windows XP - now retired by Microsoft.  This problem is a problem created my Microsoft to protect us from ourselves.  (As a non-practicing MCSE, I think the test-mode of 8.1 is a good feature... it allows knowledgeable people to disable driver signing but is not overly intuitive.)

I am running Windows 8.1 Professional 64-bit and I have installed and run both the Serial virtual port driver and the DFU driver.  However, I am running my development machine in "Test Mode"... which I explained and provided a link for some many pages back.

Safe Mode is not Test Mode
Test Mode persists across reboots.  Way back somewhere in the thread, I gave some explanation and a link back to Microsoft.  Too long to repeat same here.

@Mark_Grass
Re:
Quote
I have to say that the you are the 2nd gent from Australia that has been a major source of info. for me.
You should up that count to 3: Nick (http://www.gammon.com.au/forum/?id=11637)

Quote
3. Are you using the Arduino 1.5.x IDE to program the Maple Mini?   I've installed the 1.5.8 (have 2 DUEs on order). I've tried to upload to the maple but it doesn't work. Tried both choices for the 32bit boards.
Use 1.5.8 but be aware that things that worked in 1.5.7 are still broken in 1.5.8.  Roger gave some examples.  But we need to report against a standard IDE, so report against 1.5.8 but test first with 1.5.7 to ensure that the IDE is not the offender.  Yes it is a pain, but we are in somewhat uncharted waters here with a limited number of workers (one == roger).  So, to keep from distracting Roger and invading his personal space and livelihood, some effort to pre-digest stuff needs to occur.

Quote
I'm frustrated with the Maple mini (using Win 7 64 pro) and the DFU error.  I have 5 of them and they all respond the same way.
Be thankful!  Imagine the PIA if all 5 responded differently  :smiley-eek-blue:

Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 06, 2014, 08:40 pm
Re:Maple drivers

I have noticed that the Maple upload doesn't always manage to put the board into DFU mode.

I'm not entirely sure why this is.  If you put the board into Perpetual DFU mode, by pressing the "Button" while the led is flashing quickly, just after you press reset, this seems to allow uploads.

Or just press reset if the upload appears to have stalled.

Note. I have verbose upload and compile turned on, so its easy to see when its trying to upload.



@mrbrunette

I will take a good look at the verbose compile output today, to see what I have missed from the CooCox project build file.

As I presume everything that gcc does is listed by the IDE when in verbose mode.

I see there are compiler switches for -nostdlib but this is for the compile not link phase, and I seem to have a link issue.


@hiddenpilot

Sorry I have not replied.
Thanks for those macros, however as the PIN number is usually passed into a function, the code would need a way to use that pin number, without for example having a big switch statement.

With the Wire library, which incidentally still needs to be made faster. The approach I was going to take was to calculate the register address for the pin in question e.g. PA output register, and also calculate and store the bit patten of the pin in that register e.g. PA4

Actually for Set and Reset there are two different registers, but I think they are adjacent in memory, so either we do BASE_REG + 1 for reset or store both register addresses

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 06, 2014, 09:16 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

Re:Maple drivers

I have noticed that the Maple upload doesn't always manage to put the board into DFU mode.

I'm not entirely sure why this is.  If you put the board into Perpetual DFU mode, by pressing the "Button" while the led is flashing quickly, just after you press reset, this seems to allow uploads.

Or just press reset if the upload appears to have stalled.

Note. I have verbose upload and compile turned on, so its easy to see when its trying to upload.
Yes, same here.
It appears that some procedures prevent the DTR from resetting the COM into DFU.  It always works if I just remember to press Reset first and ensure that the Comm port has appeared under the GUI.  But, 8 out of 10 times, it just works... which is on par or better than the Pro Micro (Leo clone.)

I have the scope out today trying to get a handle on hardwareSPI... but, right now I am just frustrated and I have consumed far too much coffee.  I think I am going to go back to the MapleIDE and see if hardwareSPI works (I know the loopback did once upon a time.)



Ray
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 06, 2014, 09:40 pm
It appears that some procedures prevent the DTR from resetting the COM into DFU.
maybe because windows dtr timing can be very unpredictable in relation to other events. depending on drivers fails completely with some api. rts even worse. afaik the only way to guarantee toggling in those cases is to terminate the process before the next process like in that batch file example i posted from eevblog. it never fails. its the difference between 100% predictable bootloader entry and 99% or in some cases 0%.

avrdude routines are also very good with most usb/serial drivers in that respect and virtually never fail.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 06, 2014, 10:16 pm
Hi Ray,

I'm surprised the SPI isn't working for you.

I didn't really change much in the code. I just moved it and added the code so that SPI.c instantiated an instance of SPI  i.e so that the user doesnt need to instantiate it.

I checked mine again the other day and the cardinfo.ino demo i.e SD via SPI worked OK.
All I needed to do was assign a valid Software Select pin (I'm using PB5 but I think all unused pins should probably work for this)



BTW. I've taken another look at building inside CooCox, but didn't have any luck so far.

Looking at the Arduino build process it seems to do a load of stuff with core.a which I don't understand at the moment

e.g.

Code: [Select]
arm-none-eabi-ar rcs core.a WString.cpp.o
(I've removed all the paths but you'll get the jist ;-) )

Actually, I've not managed to build for my F4 at all yet, even any basic examples, so I guess I better make sure I don't have a fault in CooCox's installation (but I strongly suspect its Arduino's strange build process which is the problem)



One other thing I've noticed is that there are probably some defines for processor archirecture that can be merged or at least cleaned up.
This is partially my fault, as I've put in a define for __STM32F1XX__ as this seemed to be the correct format for use when modifiying existing libraries.

However I know that the new libraries are supposed to use the ARDUINO_ARCH_STM32F1XX stuff which gets generated by the IDE based on the folder name


But this lot now looks like a dogs dinner and I think it needs tidying ;-)

-DARDUINO=158
-DARDUINO_STM32F1XX_MAPLE_STM32
-DARDUINO_ARCH_STM32F1XX
-DMCU_STM32F103CB
-DSTM32_MEDIUM_DENSITY
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 07, 2014, 12:03 am
License on ST's STLink uploader ?

Guys.

I am not a lawyer (obviously), but looking at the license file for STLINK software

It looks like its possible to distribute this software.

i.e there is a really broad statement allowing

Quote
make, use, sell, offer to sell, lease, hire out, import and export or otherwise distribute Products.
Full text is


Quote
LICENSE.
STMicroelectronics (ST) grants You a non-exclusive, worldwide, non-transferable (whether by assignment or otherwise) non sub-licensable, revocable, royalty-free limited license of the Licensed Software to:
(i) make copies, prepare derivatives works, of the source code version of the Licensed Software for the sole and exclusive purpose of developing executable versions (in object and source code) of such Licensed Software only for use with the Product;
(ii) make copies, prepare derivatives works of the object code versions of the Licensed Software for the sole purpose of designing, developing and manufacturing the Products;
(iii) make, use, sell, offer to sell, lease, hire out, import and export or otherwise distribute Products.
There is this restriction

Quote
RESTRICTIONS. Unless otherwise explicitly stated in this Agreement, You may not sell, assign, sublicense, lease, rent or otherwise distribute the Licensed Software for commercial purposes, in whole or in part.
But this is non commercial



I have asked license questions on ST's forum (about libs) but didnt get a response, so there is probably no point in asking about this.


But it would be good if I could just include STLink files as part of the repo.

Title: Maple board types (not Maple mini) don't compile
Post by: rogerClark on Dec 07, 2014, 12:22 am
Guys,

FYI.

Don't select any of the Maple build types, as they don't seem to work.

I'm not sure if this worked in bobC's original version or not. I suspect not.

I know most people are using Maple mini's of other similar boards, so this is not currently a big issue ;0-)

Edit

Actually, a bin file is still created, but there are loads of warnings, so I suspect it may not work.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: mrburnette on Dec 07, 2014, 01:25 am
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

License on ST's STLink uploader ?

Guys.

I am not a lawyer (obviously), but looking at the license file for STLINK software
It looks like its possible to distribute this software.
i.e there is a really broad statement allowing
Full text is  ...
I believe you can repo this without issue.  I would stick it in a directory with the license automatically displayed as README.md


Quote
Don't select any of the Maple build types, as they don't seem to work.

I'm not sure if this worked in bobC's original version or not. I suspect not.
I know most people are using Maple mini's of other similar boards, so this is not currently a big issue ;0-)
Interesting!  I have only used the Mini to Flash.  My guess is bobC did not test beyond ensuring a bin was created for an empty sketch... Warnings neglected.

Ray

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: ChilliTronix on Dec 07, 2014, 01:40 am
The licence is clear. You can give away the software you can't sell it.

You are proposing as I understand it to include it in an open source project that is free of charge. Looks like that is OK, though obviously you would have to include their licence if you distribute their code.
Title: Re: STSTLink license
Post by: rogerClark on Dec 07, 2014, 02:09 am
@mrbrunette and @chillitronix

Thanks

I'll see if the ST-LINK_CLI.exe needs to be installed or if it will just work as an exe that I can put in the tools\win folder

I could actually put it in a sub folder if that works, and like ray says include a readme.md



FYI.

I'm looking at STM32F4 support at the moment, as my STM32F407VG board arrived yesterday, hence the interest in STLink uploads.

At the moment, although I can upload, the code doesn't run, not even blink :-(

Its hard to say at the moment quite what is going on.

I guess I'll need to dig a little deeper into the initialization code to start with

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 07, 2014, 03:09 am
I'll see if the ST-LINK_CLI.exe needs to be installed or if it will just work as an exe that I can put in the tools\win folder
it does not require installation and needs no environment variables to be set but depends on some stm32f1xx accessory files. as mentioned before ive been using that since early on to avoid pushing buttons. easiest thing to do is simply unzip the stm file into a directory and make sure the batch script references it. best to not include any drive prefixes so it works on any system.

many files are not used so anybody with time to spend can strip those out to save space. i didnt bother since its pretty compact as-is compared to some other arm flash utilities.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 07, 2014, 07:18 am
@john1993

Thanks for the info on the CLI.

I'll make a new folder under the /tools/win for STLink and put all the files in there,

I don't think there is a way to set the board type independantly from the upload method unfortunately, but I will do the new STM32F4Discovery board type as STLink as its part of the board hardware and the preferred upload method.
BTW. I did try using serial upload on PA9 and PA10 but couldn't seem to get it to work (not sure why)
Boot0 was definately pulled to Vdd, and AFIK Boot1 is pulled down via a resistor by default on the F4Discovery board

But STLink seems a much better option, its quick and reliable.

Interesting the STLink is run of a STM32F1C8 ie the same as on the Maple mini.

So if anyone was contemplating making a reliable cheap small board, I suspect a good solution would be to have 2 stm32F103C8's one as the main processor and another as a dedicated STLink  debug port.

Title: Good and bad news about STM32F4
Post by: rogerClark on Dec 07, 2014, 11:46 am
First the good news..

There is already a substantial amount of code in LibMaple for the STM32F2 which has a virtually identical peripherals memory map to the F4 (the but is considerably different from the F1)

But the bad news is that I'm not sure if the LeafLabs ever actually used the F2 code, as the code organization doesn't seem to lend its self to being able to select the F2 code instead of the F1 code.
Also, there are multiple places where there are folders for the different architectures.
Both in the original LibMaple (where I think there are at least 2 places in the code where there are folders called stm32f1 and stm32f2) and also the changes that BobC originally did, to add the variants folder (as used by the Due SAM in the official IDE hardware files)


I've made a considerable number of changes to try to remedy this, by duplicating the stm32F2 folders to become stm32f4 folders and adding a folder for it in the variants, and also had to change some things in platforms.txt and also boards.txt to move some of the compiler include path defined e.g. -Ixxx\yyy from platforms.txt to boards.txt

But I think its going to take a few more days work before it even compiles for F4, let alone works :-(

I realize that its only me at the moment that is interested to get F4 working, as I now have a F4 board, so my approach is firstly to just try to replicate the existing structure and add f4 folders etc as necessary

But ultimately, I suspect that what really needs to be done is that the code is radically restructured and all the "variant" code is actually moved into the variants folder path.

But I think that its probably best to at least get it working using the existing structure (which works for F1) before I tear it all apart



Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 07, 2014, 02:51 pm
its only me at the moment that is interested to get F4 working,
f1 is my favorite mcu atm but i would be very interested in experimenting with f4 if one can be found cheap. on ebay the chips and the boards both cost almost exactly 10 times more than f1 equivalent so im being a little cautious. can you tell me what discovery you are using and the actual part number for your chip?

interestingly it appears f3 is m4 too.
Title: SPI + SD_Card Success
Post by: mrburnette on Dec 07, 2014, 06:14 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

subtitled: I screwed up something previously!  :smiley-mr-green:


Today it works... sketch unchanged.
What I did in the past is unknown, but following Roger's connections in the previous sketch he submitted works great.

I have tried on a 1G Toshiba as well as an 8G Class 4 from MicroCenter and both work fine (for reading the directories.)  I have not written to the cards as yet.

  Sketch uses 19,964 bytes (18%) of program storage space. Maximum is 108,000 bytes.
  Data:              4,464 bytes (.data + .bss + .noinit)


Ray

From Roger's test Sketch: #538
Code: [Select]
MAPLE: SPI connections are on the Hardware SPI 1 channel
i.e
           CLK PA5 == D6
          MISO PA6 == D5
          MOSI PA7 == D4
...
// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = PB5;  // D17
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 07, 2014, 10:17 pm
Thanks Ray,

SPI to SD card also still works for me ;-)

I have however a sneaking suspicion that not every pin works as software select, I have not looked into it in any detail, but I don't think you can use the hardware software select pin for the SPI channel.

This probably needs a bit more investigation, but as it works using some other pins eg. PB5 for SS I've not looked into it in any detail.

BTW. 3 SPI functions don't have any code in them yet,

setClockDivider()
setBitOrder()
&
setMode()

I've not got around to implementing them.  well, I didnt even realize 2 of the 3 were needed until the other day when @HiddenPilot started to look at that display library ;-)

Its amazing how much wrong information there is on the web.

I'm sure by searching a few places, people were saying that the STM32 hardware SPI didn't support bit order.

However I just downloaded the reference manual for the F1,F2,F3 and F5 series

http://www.st.com/web/en/resource/technical/document/reference_manual/CD00171190.pdf (http://www.st.com/web/en/resource/technical/document/reference_manual/CD00171190.pdf)

and one page 690 it clearly lists that they support

• Programmable clock polarity and phase
• Programmable data order with MSB-first or LSB-first shifting

And the F4 also supports this

See
http://www.st.com/web/en/resource/technical/document/reference_manual/DM00031020.pdf (http://www.st.com/web/en/resource/technical/document/reference_manual/DM00031020.pdf)

page 861


So I'll need to put this on my ToDo list now that I have found the relevant reference docs!


Following on from my other post about F4 support. I've found some more places in the code where there are F1 specific folders that I don't know how to stop the IDE from compiling the code :-(

I'm going to post to one of the other forums to see if anyone can tell me how the IDE chooses which files to compile.







Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: HiddenPilot on Dec 07, 2014, 11:14 pm
@Clark/Ray

#define digitalPinToBitMask(P)     (BIT(PIN_MAP[P].gpio_bit))
#define digitalPinToPort(P)        (PIN_MAP[P].gpio_device)

it was easy and it is works. ;)
-----------------------------------------------------------------
Turn to the SPI.
Now I'm starting to study with SPI.

I think setDataMode(mode) should be written as follows:
    {spi_d->regs->SR1 |= mode;}


and in SPI.h must be:
//--#define SPI_MODE0 0x00
//--#define SPI_MODE1 0x04
//--#define SPI_MODE2 0x08
//--#define SPI_MODE3 0x0C
#define SPI_MODE0 0x01
#define SPI_MODE1 0x02
#define SPI_MODE2 0x03
#define SPI_MODE3 0x04
--------------------------------------------

setBitOrder(BitOrder) should be written as follows:
{spi_d->regs->SR1 |= BitOrder<<7;}


That is for information:
http://dics.voicecontrol.ro/dicsEE-IP/chapter/SPI%20Setup
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 07, 2014, 11:38 pm
@hiddenpilot

Thanks.

I will integrate your code.

But I can't push an update to GitHub at the moment as I'm looking at F4 support and I have changed a lot of other things ;-)

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: Mark_Grass on Dec 08, 2014, 05:06 am
Roger,   Thank you so much for your help.   I finally have the IDE uploading to the generic maple mini.  Never could get the USB to TTL to work. 

I used the F8  to boot with the  disabled signed drivers.  I'll try the policies editor now so I don't have to worry about it.

I'm still using the 1.5.8 release; I couldn't find the older version of the IDE 1.5.6.  Now that I have something to work with, I'll go back and search for the 1.5.6 release.

I was ready to put the mini on the shelf for a while.....Thanks again for your incredible help!


 
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 08, 2014, 05:18 am
Hi Mark,

No worries

I'm glad its working for you.

The only known problem on the Maple mini  is that Serial.peek() seems to crash :-(

Its on my To Do list, but I got distracted with a new STM32F4 Discovery 168Mhz board that arrived on Saturday ;-)
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: HiddenPilot on Dec 08, 2014, 06:39 am
Calrk, when you will learn F4, in the future, Can we will replace "libmaple" to "stm32 CMSIS" for "STM32F1" and "STM32F4" ? :)

Incidentally I also available F4Discovery. So I can take part in the integration process  F4Discovery to Arduino Ide ;)

But the first I need to finish a work with Maple-mini.
Title: Re: STM32F4Discovery
Post by: rogerClark on Dec 08, 2014, 09:16 am
Hi HiddenPilot

OK about STM32F4 Discovery

After spending at least 6 hours trying to modify the code to support the F4, I have decided that perhaps the best approach is to start again from scratch and not use the LibMaple code at all

Well, I may use some of it, but the hierarchy is not designed to support anything apart from STM32F1, even though there are some folders for F2 in the structure :-(

I currently have the F4 board working with CooCox and think that it would be best to use a lot of the code e.g. CMSIS etc from CooCox, rather than trying to modify libmaple

I will let you know how I get on.

In the mean time, I will revert my code back to the version that is on GitHub and look at adding those SPI functions

Cheers

Roger
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 08, 2014, 02:23 pm
hope you dont mind a reply here, i normally cant check pm and it was pure luck noticed it this time. also because at least two of my guinea pig buddies had same problem:

Could you let me know how you got the STLINK to work?

I've been testing it with a another generic stm32 board, and although I can upload, the code doesn't seem to run.

If I upload the same bin file, compiled in the arduino IDE, via serial it runs ok.
almost certainly due to the fact that the serial loader leaves some registers set up that dont happen with swd. its mentioned in one of the eevblog threads:

http://www.eevblog.com/forum/microcontrollers/one-dollar-one-minute-arm-development/

Quote
Note that the bootloader does not restore defaults but instead leaves many things initialized which can cause the user program to  run when bootloaded but fail when reset in run mode. So it's necessary to set that switch to run (BOOT0 pin low) and reset again to be sure your code works.
after some initial difficulties, following instructions there got me running in minutes. lots of great photos and examples too. pay special attention to westfw posts as he was the main contributor. that thread and the ghetto one there highly recommend for starting out. i see people struggling here with issues solved a long time ago by those guys.

btw ive ordered 10 pcs stm32f4 and some breakout boards. crystals too. total cost less than one st discovery. so hopefully youll be able to integrate that into this fantastic project too.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 08, 2014, 08:57 pm
@john1993

Thanks

I will read that link.

Edit.

I read part if that thread, but I'm not sure if that's my issue. I think at the moment I have too many unknowns.
I decided to use a different generic STM32 board that had a JTAG connector on it, and I just wired GND Sclk and data wires from the STLINK clone.

STs STLINK software communicates to the clone stlink, and seems to read the processor type etc and upload a verify the code, but even after I reset, the code doesn't run.

If I upload the same Bin file using serial to the same board, it works fine.

I will need to upload via STLINK and then download via serial and verify that the downloaded file matches the uploaded, then do the upload and download the other way around to prove both upload and download on stlink work.

I guess the other issue could be not erasing the memory pages. Ummm, this could be the problem.
I recall using the serial uploader, code only runs when I set the appropriate option for memory erasing, I.e only erase necessary pages.

Umm. Lots of options to explore.





Re F4.

I spent some time on F4 support at the weekend, but I think I will need to start again with a more strategic approach, because the more that I changed things to support F4 the more issues I found with the current organisation / hierarchy.

On the positive side, the Leaflabs guys did do some work to support the F2, which is very similar to the F4 and using their code will save a lot of time.

The issue is that there are 3 places in the code where there are folders called stm32f1, and they are not in the Variants sub tree they are in cores, and possibly in system.

I managed to control the Include of 2 of them by changing platforms.txt and boards.txt to move some of the include directives into boards.txt, so they could be switched on a board by board basis.

However there was once folder in the current organisation where this was not possible without moving it in the hierarchy structure.

Also, it looks like the code for things like GPIO is different on the F4, so the current arrangement of just changing the include paths, will only be able to change code, if there is code in the include files for GPIO etc, and I don't think this is the case at the moment, nor do I think its necessarily desirable to put code in headers just to get around this issue, when there are better more logical ways to do it.


I've been looking closely at the SAM build process, and I can now see why the compile for STM32 is slow relative to AVR and SAM

On the SAM, and probably AVR as well, a lot of the files are compiled to a library, outside of the normal compile process. And the library is just linked in from the variant folder on SAM.

This is what needs to happen on the STM32 before I start any support for F4, as will have 2 major benefits.
1. Much faster compile times
2. Better abstraction of low level from high level code.


Anyway. I will keep the forum posted in progress.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 08, 2014, 09:58 pm
you can diagnose your upload issue by simply serial flashing your program that works then resetting in run mode. if it then fails then you know it is a code problem as described.

another approach is to try one of the precompiled hex files from that site. the led toggle for example is very basic and known to work with both download methods. it would eliminate code and compiler bugs from the equation.

either way should only take a minute to narrow it down.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 08, 2014, 10:18 pm
@john1993

I just tried a few things, and I have managed to upload, however I'd like to make the whole process better

I was hoping to be able to upload without having boot0 pulled high.

i.e one of my boards has jump links on Boot0 and Boot1 and I leave Boot0 permanently set to HIGH, to allow upload via serial, however this means, if I reset the board the program doesn't run because the board is in bootloader mode.

I presumed somehow with the STLink that I could upload without needing to do this, however this is not currently the case.

If boot0 is LOW, I can't connect via STLINK

But if I press the reset button and quickly connect it seems to work (with boot0 low)

I have tried connecting the RST line from my STLink to the board and tried various different commands via the CLI but have not managed to get it to reset

Also, even if I manage to upload, by pressing reset just before the STlink attaches (or while its waiting to attach), the program uploads, but doesnt run.

Did you manage a seamless process for your upload?

What state do you have boot0 in ?
Are you using the RST line from the STLINK?

e.g. I tried  these but it didnt work for me !

Apart from the uplink bit
Code: [Select]

stlink\ST-LINK_CLI.exe -HardRst 
stlink\ST-LINK_CLI.exe -P %str% 0x8000000
stlink\ST-LINK_CLI.exe -Run 0x8000000


Thanks

Roger
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: cyclegadget on Dec 09, 2014, 02:17 am
@john1993

Quote
btw ive ordered 10 pcs stm32f4 and some breakout boards. crystals too. total cost less than one st discovery. so hopefully youll be able to integrate that into this fantastic project too.
Would you mind sharing where you got the breakout boards, please?
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 09, 2014, 02:49 am
I was hoping to be able to upload without having boot0 pulled high.
you can flash with boot0 always lo by using swd. the user program always runs right after this under stlink control. afterwards the program runs on power up or reset whether connected to the stlink or not. it is not necessary for reset to be connected to flash with swd.

in stm bootloader mode (boot0 wired hi) the user program always runs right after download as long as that option is selected in the utility. the board must always be reset before download can occur. with the batch file i posted earlier and reset wired to dtr its all automatic. reset and boot0 buttons are never touched.

that first setup is most useful if you are also taking advantage of stlink single step and breakpoint debugging. otherwise the second for no nonsense flashing and testing.

there is a third possibility of using a secondary bootloader (which is actually just another user program) like the maple one but as mentioned ive not had good luck there and it seems to cause trouble for others too.

Did you manage a seamless process for your upload?
yes, both of the above methods work reliably and flawlessly. i suggest following one or both of these procedures as described in detail in 2nd post of that eevblog thread. its only one page and the photos, files, and schematic are very helpful. or with some effort you might be able to noodle out the same info from stm docs. so far dozens if not hundreds have used these setups afaik without a single case of failure.

i also highly recommend reviewing this paulrb thread. i know its really big now but doing so helped me understand things a lot better.

btw what results did you get from the diagnostics i just suggested? one or the other should pinpoint your problem.

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 09, 2014, 03:36 am
@john1993

 Would you mind sharing where you got the breakout boards, please?
i sent out to have some custom STM32F407ZGT6 boards made at seeedstudio for around half dollar each. if you are not in a position to do this for a little more heres some on ebay:

http://www.ebay.com/itm/111075907787?_trksid=p2059210.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

fly-xy is a lot quicker than seeed but these were too big for my application and also a little pricey. if you prefer one of the smaller cousins like STM32F407VGT6 then try these:

http://www.ebay.com/itm/5pcs-QFP-TQFP-LQFP-FQFP-32-44-64-80-100-to-DIP-Adapter-PCB-Board-Converter-F16-/371103706925?pt=LH_DefaultDomain_0&hash=item5667812f2d

hes also very fast and they worked great for my lqfp48 stm32f103 parts too.

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 09, 2014, 03:58 am
Hi @John1993

I read the tread you linked to on eevblog, but it didnt contain anything I wasnt already aware of.

I have no trouble uploading via Serial, when I have boot0 high and Boot1 low , i.e I press reset on the board just after I press upload.

My bat file tells the serial loader to upload and then run from 0x8000000, so the it doesn't matter that when it boots it won't run the code, as I normally am uploading to test all the time and I can always move the boot0 link to Low to allow the code to run


I've just managed to upload my StLink clone and it now claims to be able to perform a hard reset without connecting, but I've looked at it with my scope and its not actually toggling the RST line :-(

So it looks at the moment, my best course of action is to put Boot0 back to HIGH and use STLink in much the same way as I was using the Serial Upload.

Or I may just go back to using Serial upload, because as a byproduct I get Serial comms to the PC, which the STLink doesn't give me

I guess in the long term the STLink may be useful e.g. for debugging via CooCox etc, but at the moment I don't feel its any better than using Serial
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 09, 2014, 04:17 am
youve come to exactly the same conclusions as me. serial bootloader does double duty for flashing and talking to pc so is my preferred method. the stlink was mainly for oocd debugging and for flashing the reset was not even connected. since arduino has no debugging capability and few have an stlink anyway there doesnt seem to be any point to using that for the ide.
Title: SD Card Hardware SPI(1) and Software SPI Nokia 5110
Post by: mrburnette on Dec 09, 2014, 06:18 pm
Note: Please make reference to:
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki (https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki)
For a summarized version of pertinent information contained in this lengthly
thread.  Also, some simple Mini Maple projects with source may be found on
my blog: http://www.hackster.io/rayburne (http://www.hackster.io/rayburne)

I've combined a terminal program (6 ln x 12 ch) for the Nokia GLCD and the CardInfo program for the SD Card so that the Maple Mini is using both H/W and S/W SPI in this demo as well as Serial (renamed SerialUSB) to the PC.  Serial can obviously be Serial1, Serial2, etc.

This is one of those very simplistic examples of doing several things with the sketch.  Typing just displays a monitor: ASCII 33 - 127 only.  Typing a tilde (~) invokes the SD Card Info and detailed results of the attempt to Initialize the SDCard is sent to the serial terminal to show on the PC and a quick summary is sent to the LCD.

That's it, folks.  Simple and easy test all thrown into one ZIP.  Unzip the files into a sketch directory named Nokia5110_SPI_SDCard or select your name and rename the INO.

Next, I would like to add an I2C device and have that display on the GLCD.  The idea is to compose one sketch that is easily repeatable for demonstration.

Pinouts are in the source code, for example: the GLCD:
Code: [Select]
/* Nokia GLCD
SOFTWARE SPI (using Maple Mini hardware SPI 2 Pins)
--------MapleMini----/Notes---------------------/-Nokia- */
#define PIN_SCE   31  // CE (Active High)          pin 2
#define PIN_RESET 30  // Reset (Active Lo)         pin 1
#define PIN_DC    29  // Data==1 Command==0        pin 3
#define PIN_SDIN  28  //  MOSI/DIN                 pin 4
#define PIN_SCLK  27  // CLK/clock                 pin 5


and the SDCard:
Code: [Select]
const int chipSelect = PB5;         // PB5 == D17 Maple Mini
/*
Note: The Maple SPI hardware library instantiates the following named pins on SPI channel 1:
           CLK PA5 == D6
          MISO PA6 == D5
          MOSI PA7 == D4
            CS ....== User-Defined Pin
*/


I know this thread is getting views and maybe someone wants a few examples of what can be accomplished; therefore, I hope this helps a little.

Ray


Updated: file I2C_SPI_SDcard_GLCD is same as previous but I went ahead and put in the I2C address scanner which is invoked by the '`' (Tic or backward apostrophe: correctly titled the grave accent mark)... on my keyboard, with the Tilde.

The bulk of the info is sent to the Serial port; however, the number of I2C devices are shown on the Nokia LCD.  Just one more thing to stick in a simple diag program.

Summary: Hardware SPI works, Software SPI works, Serial (over USB works on my PC), and I2C bus scans work.  I'll stick in the code for the barometer maybe tomorrow.


UPDATE 20141212:

I got around to testing the Maple Mini I2C with a Bosch BMP180 using the Jeff Rowberg  https://github.com/jrowberg/i2cdevlib library.  Works great!
Code: [Select]
I2C Scanner
Scanning...
I2C device found at address 0x77  !
Temp/Pres/Elev: 68.36øF         993.35 hPa      1048 Ft


Next step is to rearrange the code and call the BMP180 every "x" seconds, retrieve the T-T-E information and write that to the SD Card for import into Excel.  Back a couple of years ago, it seems that developing a HID class as part of the CDA class API was considered.
http://forums.leaflabs.com/topic.php?id=2283
Be kind of funky... write to an SD card but have HID automatically populate Excel, too.  Like I did here with V-USB: HID automatic population of Excel (http://www.hackster.io/rayburne/arduino-to-excel-using-v-usb)

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: john1993 on Dec 09, 2014, 08:25 pm
great. very good test of rogers new tools and your ability to document and code. ive got all the parts so im getting right on it. if i can get this to run then just about anybody can. thanks.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 09, 2014, 08:52 pm
Thanks Ray

I've not had chance to do much on the STM32 front for a few days, apart from taking a quick look a the cheap ST Link clone that I bought from eBay.
As discussed with John... At the moment there is no point anyone else buying a ST Link for Arduino development, as it gives less functionality than USB to serial.
I don't regret the few dollars I spent on it, as it allows be to upload easily from CooCox, but its not useful for Arduino development.


My test rig is similar. But has 2 I2C devices and no displays. I'm running out of space on my small breadboard. I have an i2c display that I need to get around to wiring up and testing as well.


I have quite a high workload this week, so may not be able to do much else on the STM32 device until next weekend.

Looking at F4 support wasted a lot of time last weekend, and didn't get anywhere, apart from making me realise that the code organisation still leave a lot to be desired, and that pre compiling a lot of the core files into a library is probably the next thing I should do.

I did take a look at the SPI missing functions, and as HiddenPilot has pointed out, they are not that hard to do, but it all takes time, especially to test, e.g. As I'd need to use the scope to prove if the bit order was being reversed and whether the clock edge mode was being changed ; as I don't know if I have any actual SPI devices that use reversed bit order etc.
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: HiddenPilot on Dec 10, 2014, 04:39 am
How flag in the program can be identified, for which the device is compiled code (maple or maple-mini)? _BOARD_MAPLE_MINI_H_ and _BOARD_MAPLE_H_? Is there a match better flags?
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 10, 2014, 07:05 am
Hi HiddenPilot


They way that LeafLabs did it was based on a define for the MCU

e.g.  

Maple        =          MCU_STM32F103RB


Maple Mini  =          MCU_STM32F103CB


This is defined in boards.txt

There is code that checks for this in various places

e.g. #ifdef MCU_STM32F103RB

etc

I think there are #ifdef's for other MCU types in the code, but these two are the only ones which are defined in the current boards.txt file

I should really change the type I added

maple_STM32.name=STM32 to Flash - No bootloader

to be  MCU_STM32F103C8

However I'd then need to change lots of code, so I was being lazy and just pretending that my board has more ram than it really has ;-)


Edit.

One other thing which effects what code is compiled is the variant that is set in boards.txt (thanks to WestFW for explaining this to me)

in boards.txt there is a "variant" defined for each board type e.g.

maple_STM32.build.variant=maple_mini


At the moment, the way variants is handled is OK but not perfect.

BobC did a good job to originally get it all working, but what we really need to do now is to fix platform.txt so that it uses the library that is defined in boards.txt

e.g.

maple_mini.build.variant_system_lib=libmaple.a

But.. At the moment this library does not exist, an instead of this, the IDE compiles loads of files in the variant folder each time :-(

We need to closely look at how this is handled by the SAM folder in the IDE hardware files


Also..... As I said in a previous posting.

There are issues with headers in the stm32f1 and stm32f2 folders inside the system folder.

Specifically System/libmaple/stm32f1 and System/libmaple/stm32f2

because there is an include path defined in platforms.txt as

compiler.libs.c.flags="-I{build.system.path}/libmaple"

I'm not quite sure how, but it seems to cause issues because the stm32f1 and stm32f2 folders are under this search path.
I'm not sure if the compilor / preprocessor recursively looks in folders below the -I path that has been defined, but thats what appears to be happening.

Anyway. I won't bore you with details as I may be going way off topic ;-)

Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: HiddenPilot on Dec 11, 2014, 09:13 am
@All
Just thought I'd let you know the speed test results for things like digital write
I just ran this on the Due

void setup() {
  pinMode(2, OUTPUT);
  while (2)
  {digitalWrite(2, HIGH);
    digitalWrite(2, LOW);
  }
}
void loop() {}

And my scope is showing 202Khz square wave
Ran basically same test on the STM32

void setup() {
  pinMode(PC14, OUTPUT);
  while (1)
  {digitalWrite(PC14, HIGH);
    digitalWrite(PC14, LOW);
  }
}
void loop() {}

And I'm seeing 900khz !

However a suspect a lot of this is to do with the coding of the digitalWrite
Its fairly convoluted in the SM32, so must be even more complex on the Due, otherwise it wouldnt be over 4 times slower.
I did something to improve performance digitalWrite and digitalRead.
The result of this work is very well suited to increase the transmission rate I2C
Obtained results is:
15 CPU cycles(up to 4.561MHz/Mbps) for receive data
18 CPU cycles(up to 3.805MHz/Mbps) for send data,
27 CPU cycles for transfer(SPI) data (up to 2.612MHz/Mbps).
This may allow reading/sending data speed up to 1Mhz++ to using I2C interface .  (Using with EPPROM IC for example.)

To boost up digitalWrite: I use macros and direct access to registers: BRR and BSRR (through an array PIN_MAP). As well to save CPU time / cycles, I made the table "ready masks" for each pin. Then wrote the list of masks to an array of structures "PIN_MAP" "\hardware\Arduino_STM32\ STM32F1XX\variants\maple_mini\board.cpp", and changed the file "\hardware\Arduino_STM32\STM32F1XX\cores\maple\wirish_types.h"

To boost up digitalRead: In first, I used to read data by mask from the register.
But then redid the work with the BITBAND address space for register IDR. This saved an additional 5 CPU cycles. I've generated the address table "BB_IDR" and also wrote it to an array "PIN_MAP" for each pin.

The final array "PIN_MAP" and its structure:
Code: [Select]
extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = {

    /* Top header */

    {GPIOB,   NULL, NULL, 11, 0, ADCx, 1U<<11, 0x4221812C}, /* D0/PB11 */
    {GPIOB,   NULL, NULL, 10, 0, ADCx, 1U<<10, 0x42218128}, /* D1/PB10 */
    {GPIOB,   NULL, NULL,  2, 0, ADCx, 1U<< 2, 0x42218108}, /* D2/PB2 */
    {GPIOB, TIMER3, ADC1,  0, 3,    8, 1U<< 0, 0x42218100}, /* D3/PB0 */
    {GPIOA, TIMER3, ADC1,  7, 2,    7, 1U<< 7, 0x4221011C}, /* D4/PA7 */
    {GPIOA, TIMER3, ADC1,  6, 1,    6, 1U<< 6, 0x42210118}, /* D5/PA6 */
    {GPIOA,   NULL, ADC1,  5, 0,    5, 1U<< 5, 0x42210114}, /* D6/PA5 */
    {GPIOA,   NULL, ADC1,  4, 0,    4, 1U<< 4, 0x42210110}, /* D7/PA4 */
    {GPIOA, TIMER2, ADC1,  3, 4,    3, 1U<< 3, 0x4221010C}, /* D8/PA3 */
    {GPIOA, TIMER2, ADC1,  2, 3,    2, 1U<< 2, 0x42210108}, /* D9/PA2 */
    {GPIOA, TIMER2, ADC1,  1, 2,    1, 1U<< 1, 0x42210104}, /* D10/PA1 */
    {GPIOA, TIMER2, ADC1,  0, 1,    0, 1U<< 0, 0x42210100}, /* D11/PA0 */
    {GPIOC,   NULL, NULL, 15, 0, ADCx, 1U<<15, 0x4222013C}, /* D12/PC15 */
    {GPIOC,   NULL, NULL, 14, 0, ADCx, 1U<<14, 0x42220138}, /* D13/PC14 */
    {GPIOC,   NULL, NULL, 13, 0, ADCx, 1U<<13, 0x42220134}, /* D14/PC13 */

    /* Bottom header */

    {GPIOB, TIMER4, NULL,  7, 2, ADCx, 1U<< 7, 0x4221811C}, /* D15/PB7 */
    {GPIOB, TIMER4, NULL,  6, 1, ADCx, 1U<< 6, 0x42218118}, /* D16/PB6 */
    {GPIOB,   NULL, NULL,  5, 0, ADCx, 1U<< 5, 0x42218114}, /* D17/PB5 */
    {GPIOB,   NULL, NULL,  4, 0, ADCx, 1U<< 4, 0x42218110}, /* D18/PB4 */
    {GPIOB,   NULL, NULL,  3, 0, ADCx, 1U<< 3, 0x4221810C}, /* D19/PB3 */
    {GPIOA,   NULL, NULL, 15, 0, ADCx, 1U<<15, 0x4221013C}, /* D20/PA15 */
    {GPIOA,   NULL, NULL, 14, 0, ADCx, 1U<<14, 0x42210138}, /* D21/PA14 */
    {GPIOA,   NULL, NULL, 13, 0, ADCx, 1U<<13, 0x42210134}, /* D22/PA13 */
    {GPIOA,   NULL, NULL, 12, 0, ADCx, 1U<<12, 0x42210130}, /* D23/PA12 */
    {GPIOA, TIMER1, NULL, 11, 4, ADCx, 1U<<11, 0x4221012C}, /* D24/PA11 */
    {GPIOA, TIMER1, NULL, 10, 3, ADCx, 1U<<10, 0x42210128}, /* D25/PA10 */
    {GPIOA, TIMER1, NULL,  9, 2, ADCx, 1U<< 9, 0x42210124}, /* D26/PA9 */
    {GPIOA, TIMER1, NULL,  8, 1, ADCx, 1U<< 8, 0x42210120}, /* D27/PA8 */
    {GPIOB,   NULL, NULL, 15, 0, ADCx, 1U<<15, 0x4221813C}, /* D28/PB15 */
    {GPIOB,   NULL, NULL, 14, 0, ADCx, 1U<<14, 0x42218138}, /* D29/PB14 */
    {GPIOB,   NULL, NULL, 13, 0, ADCx, 1U<<13, 0x42218134}, /* D30/PB13 */
    {GPIOB,   NULL, NULL, 12, 0, ADCx, 1U<<12, 0x42218130}, /* D31/PB12 */
    {GPIOB, TIMER4, NULL,  8, 3, ADCx, 1U<< 8, 0x42218120}, /* D32/PB8 */
    {GPIOB, TIMER3, ADC1,  1, 4,    9, 1U<< 1, 0x42218104}, /* D33/PB1 */
};

Code: [Select]
typedef struct stm32_pin_info {
    gpio_dev *gpio_device;      /**< Maple pin's GPIO device */
    timer_dev *timer_device;    /**< Pin's timer device, if any. */
    const adc_dev *adc_device;  /**< ADC device, if any. */
    uint8 gpio_bit;             /**< Pin's GPIO port bit. */
    uint8 timer_channel;        /**< Timer channel, or 0 if none. */
    uint8 adc_channel;          /**< Pin ADC channel, or ADCx if none. */
    uint32 gpio_pMASK;          /**< Pin's GPIO port MASK (HiddenPilot added to accelerate digitalWrite). */
    uint32 BB_IDR;              /**< Pin's IDR BIDBAND address (HiddenPilot added to accelerate digitalRead) */
uint8 pinMode; /**< mode specific by pinMode call (Roger Clark added to optimize compatibility with Arduino API*/
} stm32_pin_info;

macros and speed test code :
Code: [Select]
#define TestingType 1 //1 - Fast defined pin ,    3- Fast variable pin,
                      //2 - Stadart defined pin,  4- Standart variable pin

#define _digitalRead(pin) (pin < BOARD_NR_GPIO_PINS) ?  (*(volatile uint32*)PIN_MAP[pin].BB_IDR) : 0

#define _digitalWrite(pin,val) (pin < BOARD_NR_GPIO_PINS) ? (val) ? \
                               (PIN_MAP[pin].gpio_device->regs->BSRR = PIN_MAP[pin].gpio_pMASK) :\
                               (PIN_MAP[pin].gpio_device->regs->BRR  = PIN_MAP[pin].gpio_pMASK) : (NULL)
                     
#define CLK BOARD_LED_PIN
#define MISO BOARD_BUTTON_PIN
#define MOSI 31

uint8_t data;
                       
void setup() {
  pinMode(CLK, OUTPUT);
  pinMode(MOSI, OUTPUT);
  pinMode(MISO, INPUT);
    for (uint32_t i=0;i<8;i++)
    {
      pinMode(i, OUTPUT);
      pinMode(i+8, INPUT);
    }
  data = 0x92;
  Serial.begin();
}

  #define OutsideCycle 500000
  #define InsideCycle 8

void loop() {
  uint32_t startT, dur, i, j, k;
  i=0, j=0, k=1;
  startT = micros();
  for (k=0;k<OutsideCycle;k++){
 //   uint8_t SendData = data;
    for (i=0;i<InsideCycle;i++){
 
#if (TestingType == 1)
// ------SET BIT-------
//      _digitalWrite(MOSI,SendData>=0x80); // TODO: check with LA / optimize/improve?
//      SendData<<=1;
// ---- Toggle CLK ----
      _digitalWrite(CLK,HIGH);
// --- ReadBit BIT ----
      j<<=1;
      j += _digitalRead(MISO);
// -----Toggle CLK ----
      _digitalWrite(CLK,LOW);

#elif (TestingType == 2)
// ------SET BIT-------
      digitalWrite(MOSI,SendData>=0x80);
      SendData<<=1;
// ---- Toggle CLK ----
      digitalWrite(CLK,HIGH);
// --- ReadBit BIT ----
      j<<=1;
      j += _digitalRead(MISO);
// -----Toggle CLK ----
      digitalWrite(CLK,LOW);
#elif (TestingType == 3)
      _digitalWrite(i,HIGH);
      j += _digitalRead(i+8);
      _digitalWrite(i,LOW);

#elif (TestingType == 4)
      digitalWrite(i,HIGH);
      j += digitalRead(i+8);
      digitalWrite(i,LOW);
#endif   
    }
  }
  dur = micros()-startT;
  Serial.print("F:");Serial.print((uint64_t)(k*i)*1000/dur);Serial.print("kHz / ");
  Serial.print(72*dur/(k*i));Serial.print(" CPU cycles / ");
  Serial.print("dur: "); Serial.print(dur);Serial.print(" mcs");
  Serial.print(" / j="); Serial.print( j );
  Serial.print(" / i="); Serial.println(i*k);
}


ADD: code to get address/bitMASK list(for modifacation maple REV.3 STM32F1XX\variants\maple\board.cpp)
Code: [Select]
#define BB_ADDR(P,_bit_) \
    (((uint32) &(P) & 0xf0000000) | 0x02000000 \
  + (((uint32) &(P) & 0xfffff)<<5) | (_bit_<<2))

#define BB_IDR_ADDR(P,_bit_) \
    (((uint32) &(P->regs->IDR) & 0xf0000000) | 0x02000000 \
  + (((uint32) &(P->regs->IDR) & 0xfffff)<<5) | (_bit_<<2))

void setup() {Serial.begin();}

void loop() {
  delay(2000);
  // put your main code here, to run repeatedly:
  for(uint8_t i=0;i<BOARD_NR_GPIO_PINS;i++){
    Serial.print(i+1);Serial.print(": , 1U<<"); Serial.print(PIN_MAP[i].gpio_bit); Serial.print(", 0x");
    Serial.println(BB_IDR_ADDR(PIN_MAP[i].gpio_device,PIN_MAP[i].gpio_bit),16);
  }
  Serial.println("----------------------");
  delay(2000);
}
Title: Re: STM32, Maple and Maple mini port to IDE 1.5.x
Post by: rogerClark on Dec 11, 2014, 10:45 am
Hi Alexey

Sounds like a interesting solution.

Have you looked at how the OneWire library does it.

I think their solution is perhaps easier. Just have 1 function to get the register addresses and then macros which use that address.

i.e in the initialisation routine for OneWire the code gets the register for the pin, then there are macros to use that register to set and reset the bit

I realised that for maximum speed on STM32 2 registers need to be stored, i.e Set and Reset, but I think its a good solution and doesnt require many changed to the code to add to