Using STM32DUINO for commercial code development

Post here first, or if you can't find a relevant section!
Post Reply
suyog44
Posts: 7
Joined: Wed Jan 11, 2017 3:55 am

Using STM32DUINO for commercial code development

Post by suyog44 » Mon Mar 06, 2017 5:52 am

Currently I am using Atollic Truestudio for code development. But its find little bit difficult to me. Earlier i done lot of stuff with Arduino IDE and its perfect for me. Now i am using stm32duino (Great Work by Roger Clark) for commercial development. Some libraries are unstable.
I am facing some problems with libraries like I2S, UART, CAN. Please suggest some advice to build it with stm4arduino. Now i don't want to move again on Truestudio.
Last edited by suyog44 on Tue Mar 07, 2017 11:18 am, edited 2 times in total.

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

Re: Using STM4ARDUINO for commercial code development

Post by RogerClark » Mon Mar 06, 2017 6:09 am

Please see the Readme file.

https://github.com/rogerclarkmelbourne/ ... /README.md

The core is experimental and not intended for commercial use. You use it at your own risk

I'd recommend you use the official STM HAL, or Standard Peripheral Library for your commercial development.

Personally I use the manufacturers official software / SPI for commercial developments, apart from possibly when I need to build a proof of concept quickly.

Also FYI.
STM have their own Arduino core https://github.com/stm32duino but I don't think its intended to be used for commercial development either.

User avatar
mrburnette
Posts: 1788
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Using STM4ARDUINO for commercial code development

Post by mrburnette » Mon Mar 06, 2017 1:30 pm

suyog44 wrote:Currently I am using Atollic Truestudio for code development. But its find little bit difficult to me. Earlier i done lot of stuff with Arduino IDE and its perfect for me. Now i am using stm4arduino (Great Work by Roger Clark) for commercial development. Some libraries are unstable.
I am facing some problems with libraries like I2S, UART, CAN. Please suggest some advice to build it with stm4arduino. Now i don't want to move again on Truestudio.

IMO, commercial development has always been a problem with Arduino 3rd party software. Some of the software is incredibly good quality and some, well it is perhaps not ready for prime time. As the author of a paid-for program, are you ready to take on the liability of working with less-than-optimum code?

Many, if not most, libraries can easily be rewritten to lean them and to harden them - OOP on the uC is often better when distilled into working functions that can be easily tested and verified. Some libraries (Adafruit does this often) inherit from base code and then adds new functionality such as she does with the GPS parser. But, while the approach works, a few functions can be written to eliminate a lots of overhead. Many 8-bit Arduino libraries utilize buffering to handle increased thru-put, but the STM32F1xx is fast enough that often the extra buffering is not required... or can be substantially reduced.

When I did commercial work, I never had enough time, but I still wrote all of my own library code. Honestly, it is the only way that you can be certain of the quality and stability of the resulting library. You can waste a lots of time trying to stabilize an unstable library or in trying to select a replacement library - much of that time could go toward your own routines.


Ray

EDIT for example
The GPS library parses all matter of GPS sentence data; great if you need everything. But, what if you just need the time & date? Here is a snippet of how that data can be acquired with a function instead of the entire GPS library. The code is for the ESP8266. Note how simple the loop() is ....

Code: Select all

void loop()
{
  yield();       // yield for non-OS switcher
  Listener();    // UPD (can you hear me now?)
}


void Listener() {
  int packetSize = UDP.parsePacket();
  if (packetSize)
  {
    IPAddress remote = UDP.remoteIP();

    if (DIAG) {
      Serial << endl;
      Serial << (F("Received packet of size: "));
      Serial << (packetSize);
      Serial << (F(" From remote: "));
    
      for (int k = 0; k < 4; k++)
      {
        Serial << (remote[k], DEC);
        if (k < 3)
        {
          Serial << (F("."));
        }
      }
    
      Serial << (F(", port: "));
      Serial << " UDPremotePort: " << (UDP.remotePort()) << endl ;
    }

    UDP.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    UDP.beginPacket(apIP, UDP.remotePort());
    UDP.write(ReplyBuffer);
    UDP.endPacket();
    char *p = packetBuffer;

    if (DEMO)
      {
      p = strchr(p, ',') + 1; // position after 1st comma
      yield();
      uint32_t  time  = atoi(p);
      hour    = time / 10000;
      minute  = (time % 10000) / 100;
      seconds = (time % 100);
      Serial << (F("Time: ")) << ((hour<10)?"0":"") << hour << ":" ; 
      Serial << ((minute<10)?"0":"") << minute << ":" ; 
      Serial << ((seconds<10)?"0":"") << seconds << endl;

      
      // Parse to integer date field
      p = strchr(p, ',') + 1; // A/V?
      p = strchr(p, ',') + 1; // lat
      p = strchr(p, ',') + 1; // N/S?
      p = strchr(p, ',') + 1; // lon
      p = strchr(p, ',') + 1; // E/W?
      p = strchr(p, ',') + 1; // speed
      p = strchr(p, ',') + 1; // angle
      p = strchr(p, ',') + 1; // move pass for date DDMMYY

      delay(0);

      // nmea date field looks like: 090914 (European)
      uint32_t fulldate = atoi(p);
      day               = (fulldate / 10000);
      month             = (fulldate % 10000) / 100;
      year              = (fulldate % 100);
      Serial << "Date: " << ((month<10)?"0":"") << month << "/" ; 
      Serial << ((day<10)?"0":"") << day << "/" << "20" ; 
      Serial << ((year<10)?"0":"") << year << endl;
    } else {
      Serial << endl << packetBuffer << endl;
    }

    yield();

    digitalWrite(LEDpin, !(digitalRead(LEDpin)));               // blink'n the LED
  }                                                             // if(packetSize)
}
Full code is available on my projects page for Tardis Time
Last edited by mrburnette on Mon Mar 06, 2017 5:48 pm, edited 2 times in total.

User avatar
Rick Kimball
Posts: 895
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Using STM4ARDUINO for commercial code development

Post by Rick Kimball » Mon Mar 06, 2017 3:52 pm

suyog44 wrote:... Now i am using stm4arduino (Great Work by Roger Clark) for commercial development. ...
What is stm4arduino ?
-rick

victor_pv
Posts: 1341
Joined: Mon Apr 27, 2015 12:12 pm

Re: Using STM4ARDUINO for commercial code development

Post by victor_pv » Mon Mar 06, 2017 5:01 pm

Rick Kimball wrote:
suyog44 wrote:... Now i am using stm4arduino (Great Work by Roger Clark) for commercial development. ...
What is stm4arduino ?
It's what comes after stm32duino, and before stm65duino ;)

suyog44
Posts: 7
Joined: Wed Jan 11, 2017 3:55 am

Re: Using STM4ARDUINO for commercial code development

Post by suyog44 » Tue Mar 07, 2017 11:25 am

Recently Texas TIVA C based MCU using their IDE which is quite similar to Arduino. Till now i doesn't used it, But when i saw the overall functionality and support side for it. Its found quite time saver and interesting. We can also put effort together to make powerful stuff like that which is able to use for commercial development as well rather than only use for exeperimental projects.
mrburnette wrote:
suyog44 wrote:Currently I am using Atollic Truestudio for code development. But its find little bit difficult to me. Earlier i done lot of stuff with Arduino IDE and its perfect for me. Now i am using stm4arduino (Great Work by Roger Clark) for commercial development. Some libraries are unstable.
I am facing some problems with libraries like I2S, UART, CAN. Please suggest some advice to build it with stm4arduino. Now i don't want to move again on Truestudio.

IMO, commercial development has always been a problem with Arduino 3rd party software. Some of the software is incredibly good quality and some, well it is perhaps not ready for prime time. As the author of a paid-for program, are you ready to take on the liability of working with less-than-optimum code?

Many, if not most, libraries can easily be rewritten to lean them and to harden them - OOP on the uC is often better when distilled into working functions that can be easily tested and verified. Some libraries (Adafruit does this often) inherit from base code and then adds new functionality such as she does with the GPS parser. But, while the approach works, a few functions can be written to eliminate a lots of overhead. Many 8-bit Arduino libraries utilize buffering to handle increased thru-put, but the STM32F1xx is fast enough that often the extra buffering is not required... or can be substantially reduced.

When I did commercial work, I never had enough time, but I still wrote all of my own library code. Honestly, it is the only way that you can be certain of the quality and stability of the resulting library. You can waste a lots of time trying to stabilize an unstable library or in trying to select a replacement library - much of that time could go toward your own routines.


Ray

EDIT for example
The GPS library parses all matter of GPS sentence data; great if you need everything. But, what if you just need the time & date? Here is a snippet of how that data can be acquired with a function instead of the entire GPS library. The code is for the ESP8266. Note how simple the loop() is ....

Code: Select all

void loop()
{
  yield();       // yield for non-OS switcher
  Listener();    // UPD (can you hear me now?)
}


void Listener() {
  int packetSize = UDP.parsePacket();
  if (packetSize)
  {
    IPAddress remote = UDP.remoteIP();

    if (DIAG) {
      Serial << endl;
      Serial << (F("Received packet of size: "));
      Serial << (packetSize);
      Serial << (F(" From remote: "));
    
      for (int k = 0; k < 4; k++)
      {
        Serial << (remote[k], DEC);
        if (k < 3)
        {
          Serial << (F("."));
        }
      }
    
      Serial << (F(", port: "));
      Serial << " UDPremotePort: " << (UDP.remotePort()) << endl ;
    }

    UDP.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    UDP.beginPacket(apIP, UDP.remotePort());
    UDP.write(ReplyBuffer);
    UDP.endPacket();
    char *p = packetBuffer;

    if (DEMO)
      {
      p = strchr(p, ',') + 1; // position after 1st comma
      yield();
      uint32_t  time  = atoi(p);
      hour    = time / 10000;
      minute  = (time % 10000) / 100;
      seconds = (time % 100);
      Serial << (F("Time: ")) << ((hour<10)?"0":"") << hour << ":" ; 
      Serial << ((minute<10)?"0":"") << minute << ":" ; 
      Serial << ((seconds<10)?"0":"") << seconds << endl;

      
      // Parse to integer date field
      p = strchr(p, ',') + 1; // A/V?
      p = strchr(p, ',') + 1; // lat
      p = strchr(p, ',') + 1; // N/S?
      p = strchr(p, ',') + 1; // lon
      p = strchr(p, ',') + 1; // E/W?
      p = strchr(p, ',') + 1; // speed
      p = strchr(p, ',') + 1; // angle
      p = strchr(p, ',') + 1; // move pass for date DDMMYY

      delay(0);

      // nmea date field looks like: 090914 (European)
      uint32_t fulldate = atoi(p);
      day               = (fulldate / 10000);
      month             = (fulldate % 10000) / 100;
      year              = (fulldate % 100);
      Serial << "Date: " << ((month<10)?"0":"") << month << "/" ; 
      Serial << ((day<10)?"0":"") << day << "/" << "20" ; 
      Serial << ((year<10)?"0":"") << year << endl;
    } else {
      Serial << endl << packetBuffer << endl;
    }

    yield();

    digitalWrite(LEDpin, !(digitalRead(LEDpin)));               // blink'n the LED
  }                                                             // if(packetSize)
}
Full code is available on my projects page for Tardis Time

User avatar
mrburnette
Posts: 1788
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Using STM4ARDUINO for commercial code development

Post by mrburnette » Tue Mar 07, 2017 1:33 pm

suyog44 wrote:Recently Texas TIVA C based MCU using their IDE which is quite similar to Arduino. Till now i doesn't used it, But when i saw the overall functionality and support side for it. Its found quite time saver and interesting. We can also put effort together to make powerful stuff like that which is able to use for commercial development as well rather than only use for exeperimental projects.
The below is not directed specifically to suyog44; I am just using the post as my platform for this little Speaker's Corner post:

I'm afraid that many of the younger members in the forum do not understand my stance on this forum and on development in general. I'm not around much these days but do read the bulk of posts.

The forum name, STM32duino should give everyone a clue that the effort here was originally a derivative of the Leaflabs STM32 project which used a pre-1.0 Arduino core and a customized Arduino version. Efforts by many Arduino.cc forum members took us to a 1.5'ish compatible core that would run under the then downloadable version of Arduino. Shortly after that, Roger created this forum site and all of the effort for maintenance of the newly ported STM32F1xx Arduino core moved here. Since that time, Roger has managed the core in github. The forum was created not only to move the STM32F1xx core off of the Arduino.cc site, but also to provide a place that the core could evolve - but, the emphasis was on advance users who had need of a more powerful hardware platform than what the 8-bit Arduinos could provide; that is, more flash and more SRAM.

Now, with effort, any Arduino core can be made to work with Eclipse and many other IDEs. Sharing that knowledge and providing proof-of-concepts and user guides has been the primary thrust of advanced users here in the STM32duino while all the time remembering that the duino in the forum name implies that everything will continue to function appropriately with the current downloadable (or recent) version of the ArduinoIDE. As we are advanced users, we may have other IDEs that we use for work or commercial application development, but whatever happens to the core as it evolves should align itself with ArduinoIDE.

I use 3rd party libraries, very often. It is easy and as I author lots of projects, it is easy for my readers, too. But, most 3rd party libraries are not what I would write myself. My normal way of doing things are to bring all of the libraries into the sketch folder (makes it easy to do one ZIP to distribute and avoids any conflicts with newer/older versions) and then hack the hell out of those libraries ... adding and removing to my content. Nothing gets left in the code that I do not understand and have reviewed - this does two things, it makes the code my own and it means that I take responsibility for what stays in my program. The "my own" means that I have a tested and validated the correctness of the code and that I can now catalyze another sketch with the changes where the modified routines may live as-is or evolve yet again. Often, after a few revisions, the code is nothing like the original library from which it was derived.

When I publish, it is always for the ArduinoIDE that is currently shipping at that moment. Roger may suggest a lower version, but I verify and test to the current the specific sketch being published with the current IDE. It is absolutely silly to publish an article and then tell the user that they must download an older version of the IDE to get things to work. As the programmer, I think it is my responsibility to validate the sketch and assure my readers it will work at the current version ... NOW, a year down the road if a reader complains about errors with a newer IDE, I simply send them a link to the archive where they can download an older IDE version: I may or may not go back and correct the original article. It is my opinion that going back constantly to refresh published articles is simply not warranted. However, I have a personal folder under the STM32F1 folder on my development machine that has a variety of example sketches and these do get re-validated with each IDE release.

The code you publish should run under the current ArduinoIDE.

Whatever libraries are supporting your program, you need to be capable of making changes in those libraries. Roger maintains a section of this forum for ported libraries. For those reading this message who cannot port a library, that is not my problem for a site that caters to advanced programming. I realise we have some newbie members that have jumped on the STM32F103 bandwagon and do not have the expertise to port a library and to them I strongly suggest that they study and learn the skills necessary to support their own projects. Reliance on someone else to write & maintain a piece of code you use is not smart. It does take time to gain the skills, but you will learn faster by digging-in and struggling. We have folks here that likely will not let you drown, but no guarantees!


Ray

User avatar
BennehBoy
Posts: 420
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Using STM32DUINO for commercial code development

Post by BennehBoy » Tue Mar 07, 2017 2:10 pm

Mostly agree, this maxim still holds well: TANSTAAFL (and it just happens to be used in one of my favourite books)

I'd just say that the higher that the bar for entrance is set the more slowly the community is likely to grow, and progress is most likely a function of size (although not a direct correlation :D ).
-------------------------------------
https://github.com/BennehBoy

Ollie
Posts: 171
Joined: Thu Feb 25, 2016 7:27 pm

Re: Using STM32DUINO for commercial code development

Post by Ollie » Tue Mar 07, 2017 3:57 pm

Ray,

I like your approach and the logic behind that.

Post Reply

Who is online

Users browsing this forum: JensEP and 2 guests