[STM32GENERIC] F746 Discovery

Discussions about the STM32generic core
ChrisMicro
Posts: 308
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: [STM32GENERIC] F746 Discovery

Post by ChrisMicro » Thu Aug 17, 2017 4:59 am

I just realized the tft buffer malloc should be * 2, because 1 pixel is 2 bytes.
Thanks. I have corrected all TFT-examples.
But the code actually sometimes works (prints users online to display), sometimes fails to client.connect("www.stm32duino.com", 80)
I'm not sure if this is a matter how fast the stm32duino-website is responding. Hopefully Roger's server does not get a DDS attack from some STM32F746 discoveries :shock:
Last edited by ChrisMicro on Fri Aug 18, 2017 7:26 pm, edited 1 time in total.

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

Re: [STM32GENERIC] F746 Discovery

Post by fpiSTM » Thu Aug 17, 2017 6:58 am

FYI: the ethernet libs has been released and should be available soon thanks the library manager

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

Re: [STM32GENERIC] F746 Discovery

Post by ChrisMicro » Thu Aug 17, 2017 8:13 am

Here is a new version of poling the stm32duino users.

Let's call it a "ethernet" test:

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 requestSTM32duino()
{
  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, waiting for response");
}

uint32_t startTime;

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(2*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");
  tft.println("Connecting to Ethernet");
  delay(1000);

  if (!Ethernet.begin(mac)) {
    Serial.println("ERROR: Could not connect to ethernet!");
    tft.println("ERROR: Could not connect to ethernet!");
    tft.println("program stopped, press reset to restart");
    while (1);
  }

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

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

    Serial.println("ERROR: Could not connect to www.stm32duino.com!");
    tft.println("ERROR: Could not connect to www.stm32duino.com!");
    tft.println("program stopped, press reset to restart");

    while (1);
  }

  requestSTM32duino();
  startTime=millis();
}

// Freestack is found here
// https://github.com/greiman/SdFat-beta/blob/master/SdFat/src/FreeStack.h#L45
// from William Greiman
#if defined(__arm__)
extern "C" char* sbrk(int incr);
static int FreeStack() {
  char top = 't';
  return &top - reinterpret_cast<char*>(sbrk(0));
}
#endif

String str;
int FailedCounter=0;

void loop() 
{
  if (client.available()) 
  {
    FailedCounter=0;
    char c = client.read();

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

    tft.print(".");
    if(tft.getCursorY()>260)
    {
      tft.fillScreen(LTDC_BLACK); // cls
      tft.setCursor(0,0);
    }
    delay(1000);
    FailedCounter++;
    if ( FailedCounter > 30 )
    {
      requestSTM32duino(); // send new request on timeout
      FailedCounter=0;
    }
  }

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

    while (1);
  }
  if(millis()-startTime>10000)
  {
    //tft.println("alive");
    tft.print("stack: ");tft.println(FreeStack());
    startTime=millis();
  }
}

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

Re: [STM32GENERIC] F746 Discovery

Post by ChrisMicro » Thu Aug 17, 2017 9:59 am

Here I adapted the NTP-time-client.
Now your can see the UTC-internet time on the TFT.
Last edited by ChrisMicro on Tue Aug 29, 2017 6:03 am, edited 1 time in total.

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

Re: [STM32GENERIC] F746 Discovery

Post by ChrisMicro » Fri Aug 18, 2017 2:03 pm

Here I've made a transmission over the ethernt for pictures by UDP.

My hope was to achieve something close to "video speed" but than I realized that the Arduino-UDP only supports packet lengths up to 24 bytes. This results more like a speed like in the teletype-era.

I've put the picture in the ethernet thread:
http://www.stm32duino.com/viewtopic.php ... 447#p33151

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

Re: [STM32GENERIC] F746 Discovery

Post by danieleff » Fri Aug 18, 2017 4:47 pm

I am having trouble downloading large files. After a few KB it just stops.
I can fix by disabling heap in external ram (by commenting out `setHeap` in variant.cpp)
So I guess there is some problem with it (but the display uses it, internal ram is not enough).
The external ram setup is in STM32\system\STM32F7\HAL_Src\system_stm32f7xx.c , but it is basically a copy of STM32Cube_FW_F7_V1.7.0\Projects\STM32746G-Discovery\Examples\FMC\FMC_SDRAM\Src\system_stm32f7xx.c so I'm not sure.

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

Re: [STM32GENERIC] F746 Discovery

Post by ChrisMicro » Fri Aug 18, 2017 5:40 pm

I am having trouble downloading large files. After a few KB it just stops.
Dowload with ethernet?

During my experiments with UDP today I realized that the system crashes when the PC sends a UDP packet larger than 24bytes.
I didn't expect that there is such a small UDP payload buffer in the driver.
Possibly the reason of the crashes is somewhere in the ethernet drivers. I don't know.

zmemw16
Posts: 1486
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: [STM32GENERIC] F746 Discovery

Post by zmemw16 » Fri Aug 18, 2017 8:10 pm

65,507 bytes
The field size sets a theoretical limit of 65,535 bytes (8 byte header + 65,527 bytes of data) for a UDP datagram. However the actual limit for the data length, which is imposed by the underlying IPv4 protocol, is 65,507 bytes (65,535 − 8 byte UDP header − 20 byte IP header).
srp

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

Re: [STM32GENERIC] F746 Discovery

Post by ChrisMicro » Fri Aug 18, 2017 9:03 pm

I think the variable in the normal Arduino EthernetUdp is set to

#define UDP_TX_PACKET_MAX_SIZE 24

and on a Arduino Uno with its 2K-Ram it can probably not be any longer.

from
https://github.com/arduino-libraries/Et ... ernetUdp.h
in line 42:

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

Re: [STM32GENERIC] F746 Discovery

Post by ChrisMicro » Wed Aug 30, 2017 8:09 am

I just discovered that there is a EEPromEmulation example in the STM32GENERIC repo:
It is not compiling.

Post Reply