LWIP_TCPIP_THREAD - stack size limit reached?

I am assuming that this is the thread that is reaching a limit of 1200 when printing thread stack statistics. It is an OS thread, as I do not have any of my own with that size stack limit. After a couple of web server requests, it reports that the MaxStack is equal to the Stack size. Is this normal.

Tried changing the definition in mbed_config.h - but it had no effect - ? may have to recompile whole OS to change it.

Thanks

Hello,

the mbed_config.h file has very important note at the beginning

// Automatically generated configuration file.
// DO NOT EDIT, content will be overwritten.

For changing stack size and many more gonfiguration you need create/edit mbed_app.json file. For more information and better understanding look to - The configuration system - Program setup | Mbed OS 6 Documentation

The default value of parameter tcpip-thread-stacksize is in the mbed_lib.json here.
The override of that parameter via mbed_app.json file might look like this

{
    "target_overrides": {
      "*": {
        "lvip.tcpip-thread-stacksize": 2000
      }
    }
}

BR, Jan

Thanks - I am using an Arduino Portenta H7 as my device. I tried adding the mbed_app.json with the following contents in my project root directory (where the arduino code resides). My main thread stack never exceeds 3k - as it does nothing after the initializations, except sleep forever - so I modified that as well.

{
    "target_overrides": {
        "*": {
            "target.lse_available": "1",
			"lwip.tcpip-thread-stacksize": 4096,
			"rtos.main-thread-stack-size": 8192
		}
    }
 }


However, when running the program, there is no difference in the Max Stack sizes reported.

      Thread: 0x2400ee1c, Stack size: 32768, Max stack: 2824
      Thread: 0x2400f728, Stack size: 1200, Max stack: 168

Should I be adding the mbed_app.json file somewhere else? There is very little support on this subject in the Portenta forums.

Thanks again.

How I remember Arduino does not use Mbed OS 1:1 , it is wrapped in some patches.
So you need to research Arduino sources. Good start seems to be here - ArduinoCore-mbed - Customizing Mbed OS build without modifying the code

BR, Jan

Thanks, I had seen that before, and I had tried in a number of locations before to no avail.

It is now OS 3.2, and I have tried modifying the standard mbed_app.json in

C:\Users\RS\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.2.0\variants\PORTENTA_H7_M7\libs

as well as adding it to a number of other directories under variants, but it is never accessed (as per properties), and does not change the stack sizes as per the entries.

I closed and reopened the IDE, to force a clean compile as well.

???

The complete mbed_app,json file - including the preexisting mods is

{
  "target_overrides": {
    "*": {
      "target.printf_lib": "std",
      "platform.stdio-buffered-serial": false,
      "platform.stdio-baud-rate": 115200,
      "platform.default-serial-baud-rate": 115200,
      "platform.callback-nontrivial": true,
      "platform.all-stats-enabled": true,
      "platform.memory-tracing-enabled": true,
			"lwip.tcpip-thread-stacksize": 4096,
			"rtos.main-thread-stack-size": 8192,
      "cordio.max-connections": 5,
      "cellular.debug-at": true,
      "cellular.offload-dns-queries": true,
      "cellular.at-handler-buffer-size": 512,
      "mbed-trace.enable": true,
      "target.mbed_app_start": "0x8040000",
      "target.macros_add": [
        "BT_UART_NO_3M_SUPPORT",
        "USB_DYNAMIC_CONFIGURATION",
        "METAL_INTERNAL",
        "VIRTIO_MASTER_ONLY",
        "NO_ATOMIC_64_SUPPORT",
        "METAL_MAX_DEVICE_REGIONS=2",
        "RPMSG_BUFFER_SIZE=2048"
      ]
    }
  }
}

According to

the path should be PORTENTA_H7_M7\conf and not PORTENTA_H7_M7\libs

BR, Jan

Sorry, that was a cut and paste issue.

I tried it in the \conf directory,

I also tried it in the base directory (above conf), my sketch project root directory, i created a conf directory in my project, and added it there as well.

None of them seem to have mace a difference,

Unless the contents of tbe mbed_app.json file is issue (i have no other way to test that).

Ok, I am out of ideas, last tip. Are you sure you have selected the PORTENTA_H7_M7 and not the PORTENTA_H7_M4?

BR, Jan

afaik, the Arduino-Mbed core is using a precompiled archive for the core, so the mbed-app.json cannot have an effect on the mbed core settings. I guess you need to compile a new core archive.

Unfortunately, I had Pretty frustrating.

Recompiling the mbed core is not a very windows friendly procedure.

I tried

and the boards do not appear in the IDE, also, I do not think the ./mbed-os-to-arduino runs under windows.

I have access to a raspberry pi, should I try it under that, create a new libmbed.a file and try moving iot to the directory below?

C:\Users\RS\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\3.2.0\variants\PORTENTA_H7_M7\libs

I am working in Windows, not Linux

I downloaded Cygwin

I also downloaded and installed mingw64 – and verified I can compile a .cpp programs with g++

I then downloaded the repositiory

Made the changes in the conf/mbed_app.json file

I then go to the root of the repository, and execute

./mbed-os-to-arduino -r ./variants/PORTENTA_H7_M7/libs PORTENTA_H7_M7:PORTENTA_H7_M7

And, I get the following error message

$ ./mbed-os-to-arduino -r ./variants/PORTENTA_H7_M7/libs PORTENTA_H7_M7:PORTENTA_H7_M7

./mbed-os-to-arduino: line 2: $‘\r’: command not found

: invalid optionuino: line 3: set: -

set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [–] [arg …]

./mbed-os-to-arduino: line 4: $‘\r’: command not found

./mbed-os-to-arduino: line 5: syntax error near unexpected token `$‘{\r’’

'/mbed-os-to-arduino: line 5: `check_tools () {

Any ideas?

I tried running it is a Raspberry Pi 4 that I have

I downloaded and extracted the repository in a directory.

I cd to that directory

I run

$ ./mbed-os-to-arduino -r ./variants/PORTNETA_H7_M7/libs PORTENTA_H7_M7:PORTENTAA_H7_M7

I then get this error

MBED_CLEAN=0

MBED_UPDATE=0

APPLY_PATCHES=0

RESTORE_GDB_INFO=0

LOCAL_REPO=./variants/PORTENTA_H7_M7/libs

REMOTE_BRANCH=

MBED_CORE_LOCATION=/home/rsalasidis/GithubRep/ArduinoCore-mbed-master

VARIANT=PORTENTA_H7_M7 BOARD=PORTENTA_H7_M7

Checking for prerequisites… done.

Creating MbedOS Application…/mbed-os-to-arduino: line 25: mbed: command not found

I tried to run the above line in the mbed_cli (that I installed as well), and I get

‘mbed-os-to-arduino’ is not recognized as an internal or external command,

operable program or batch file.

Any idea the easiest way to do this.

Via the mbed_studio in windows probably be the easiest for me if possible

Thanks