[STM32GENERIC] F746 Discovery

Discussions about the STM32generic core
fpiSTM
Posts: 250
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: [STM32GENERIC] F746 Discovery

Post by fpiSTM » Thu Aug 10, 2017 6:43 am

No, only means that libraries could be common.

ChrisMicro
Posts: 308
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: [STM32GENERIC] F746 Discovery

Post by ChrisMicro » Fri Aug 11, 2017 10:25 am

danieleff wrote:
Wed Aug 09, 2017 1:30 pm
It uses drivers the official drivers Frederic talked about here: viewtopic.php?f=51&t=2220&start=10#p31084

They are still under pull request. The top of the example file has comments on how to install. They are in a different repo + branch, so you cannot just download it from github as zip.
I installed all the libs but some paths seem to be missing:
In file included from C:\Tools\Arduino\Arduino1_8\hardware\STM32GENERIC\STM32\libraries\STM32Ethernet\src/EthernetClient.h:7:0,

from C:\Tools\Arduino\Arduino1_8\hardware\STM32GENERIC\STM32\libraries\STM32Ethernet\src/STM32Ethernet.h:6,

from C:\Tools\Arduino\Arduino1_8\hardware\STM32GENERIC\STM32\libraries\BoardExamples\examples\Discovery746NG\Ethernet\Ethernet.ino:20:

C:\Tools\Arduino\Arduino1_8\hardware\STM32GENERIC\STM32\libraries\STM32Ethernet\src/utility/stm32_eth.h:47:26: fatal error: lwip/ip_addr.h: No such file or directory

#include "lwip/ip_addr.h"

fpiSTM
Posts: 250
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: [STM32GENERIC] F746 Discovery

Post by fpiSTM » Fri Aug 11, 2017 12:08 pm

They are standalone libraries for Arduino.
Install them in the

Code: Select all

libraries 
folder not in

Code: Select all

libraries\BoardExamples\examples\Discovery746NG

ChrisMicro
Posts: 308
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: [STM32GENERIC] F746 Discovery

Post by ChrisMicro » Fri Aug 11, 2017 3:13 pm

Thank you for the reply. But there seems to be no change:
In file included from C:\Tools\Arduino\Arduino1_8\libraries\STM32Ethernet\src/EthernetClient.h:7:0,

from C:\Tools\Arduino\Arduino1_8\libraries\STM32Ethernet\src/STM32Ethernet.h:6,

from C:\Tools\Arduino\Arduino1_8\hardware\STM32GENERIC\STM32\libraries\BoardExamples\examples\Discovery746NG\Ethernet\Ethernet.ino:20:

C:\Tools\Arduino\Arduino1_8\libraries\STM32Ethernet\src/utility/stm32_eth.h:47:26: fatal error: lwip/ip_addr.h: No such file or directory

#include "lwip/ip_addr.h"
The missing file is located in

C:\Tools\Arduino\Arduino1_8\libraries\LwIP\src\lwip

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: [STM32GENERIC] F746 Discovery

Post by danieleff » Fri Aug 11, 2017 4:39 pm

Ah, put `#include "LwIP.h"` in the .ino. Pushed a commit for it.
I use Eclipse with sloeber and always hand pick the libraries, did not realize Arduino IDE will not include it automatically.

As for how how to keep the drivers with the core: Frederic, did you think about putting it into the board manager package? When creating the zip file, include the extra STM32 libraries. That is what Teensy does. The core is one repo, and all the libraries are their own repositories. And when you install it, everything is packed into one.

fpiSTM
Posts: 250
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: [STM32GENERIC] F746 Discovery

Post by fpiSTM » Fri Aug 11, 2017 7:55 pm

I never think about that but it could be discuss. I will check what teensy does.

ChrisMicro
Posts: 308
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: [STM32GENERIC] F746 Discovery

Post by ChrisMicro » Sun Aug 13, 2017 6:16 am

Now it is compiling.
I tried to read the "www.stm32duino.com" number of users line. It works when I use only the serial port.
When I include the tft-display it does not work. So there seems to be a conflict between ethernet and tft.
What can it be? Is it memory? Is it timing?

Code: Select all

// Example for the onboard ethernet connector
//
// Install https://github.com/stm32duino/LwIP
//     and https://github.com/stm32duino/STM32Ethernet
//
// If they are empty, install the work in progress versions using git:
//    cd <your arduino library folder>
//    git clone https://github.com/fprwi6labs/LwIP.git
//    cd LwIP
//    git checkout LwIP_src
//
//    cd ..
//    git clone https://github.com/fprwi6labs/STM32Ethernet.git
//    cd STM32Ethernet
//    git checkout add_src
//
//
// For more examples, check the STM32Ethernet examples folder

#include <LwIP.h>
#include <STM32Ethernet.h>

#include "LTDC_F746_Discovery.h"

LTDC_F746_Discovery tft;

EthernetClient client;

// random MAC address
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

void setup() {
  
    // The buffer is memory mapped
  // You can directly draw on the display by writing to the buffer
  uint16_t *buffer = (uint16_t *)malloc(LTDC_F746_ROKOTECH.width * LTDC_F746_ROKOTECH.height);

  tft.begin((uint16_t *)buffer);
  tft.fillScreen(LTDC_BLACK);
    tft.setCursor(0, 0);
  tft.setTextColor(LTDC_GREEN);  tft.setTextSize(3);
  tft.println("STM32F746 Discovery");
  tft.setTextColor(LTDC_YELLOW); tft.setTextSize(2);
  
  Serial.begin(115200);

  Serial.println("Connecting to Ethernet");
  delay(1000);

  if (!Ethernet.begin(mac)) {
    Serial.println("ERROR: Could not connect to ethernet!");

    while (1);
  }

  Serial.println("Connecting to www.stm32duino.com");

  //if (!client.connect("example.com", 80)) {
  if (!client.connect("www.stm32duino.com", 80)) {

    Serial.println("ERROR: Could not connect to www.stm32duino.com!");

    while (1);
  }

  Serial.println("Connected, sending request");

  client.println("GET / HTTP/1.1");

  client.println("Host: www.stm32duino.com");
  client.println("User-Agent: Mozilla//5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko//20100101 Firefox//54.0");
  client.println("Accept: text//html,application//xhtml+xml,application//xml;q=0.9,*//*;q=0.8");
  client.println("Accept-Language: en-US,en;q=0.5");
  //client.println("Accept-Encoding: gzip, deflate");
  client.println("Cookie: phpbb3_4im1j_u=1; phpbb3_4im1j_k=; ");
  client.println("DNT: 1");
  client.println("Connection: keep-alive");
  client.println("Upgrade-Insecure-Requests: 1");

  client.println();
  client.flush();

  Serial.println("Request sent, printing response");
}

String str;
boolean flag = false;
void loop() {

  if (client.available()) {
    char c = client.read();

    if (c != '>')str += c;
    else
    {
      if (str.indexOf("users online") > 0)
      {
        flag=true;
        Serial.print("====> ");
        Serial.println(str);
        tft.println(str);
      }
      str = "";

    }
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    while (1);
  }
}

fpiSTM
Posts: 250
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: [STM32GENERIC] F746 Discovery

Post by fpiSTM » Sun Aug 13, 2017 5:42 pm

I do not know/check how Daniel integrated it but it could be a clue:

https://github.com/stm32duino/STM32Ethe ... 2eec7d8R21
An Idle task is required by the LwIP stack to handle timer and data reception.
This idle task is called inside the main loop in background by the function
stm32_eth_scheduler(). Be careful to not lock the system inside the function
loop() where LwIP could never be updated. Call EthernetUDP::parsePacket() or
EthernetClient::available() performs an update of the LwIP stack.
Call done in the main loop:
https://github.com/stm32duino/Arduino_C ... fc7dda4R49

Edit: Seems no call of the stm32_eth_scheduler is made, so probably it's the root cause.

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: [STM32GENERIC] F746 Discovery

Post by danieleff » Tue Aug 15, 2017 6:09 am

fpiSTM wrote:
Sun Aug 13, 2017 5:42 pm
I do not know/check how Daniel integrated it but it could be a clue:

https://github.com/stm32duino/STM32Ethe ... 2eec7d8R21
An Idle task is required by the LwIP stack to handle timer and data reception.
This idle task is called inside the main loop in background by the function
stm32_eth_scheduler(). Be careful to not lock the system inside the function
loop() where LwIP could never be updated. Call EthernetUDP::parsePacket() or
EthernetClient::available() performs an update of the LwIP stack.
Call done in the main loop:
https://github.com/stm32duino/Arduino_C ... fc7dda4R49

Edit: Seems no call of the stm32_eth_scheduler is made, so probably it's the root cause.

Code: Select all

if (client.available()) {
calls `stm32_eth_scheduler();` on every loop, so I don't think its that.

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: [STM32GENERIC] F746 Discovery

Post by danieleff » Tue Aug 15, 2017 5:38 pm

I just realized the tft buffer malloc should be * 2, because 1 pixel is 2 bytes.

But the code actually sometimes works (prints users online to display), sometimes fails to client.connect("www.stm32duino.com", 80)

Post Reply