Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Getting started with stm32f429zi (Nucleo f429zi) with Zephyr RTOS : Async HTTP Server, DHCP, UDP, ...

Notifications You must be signed in to change notification settings

lucasdietrich/stm32f429zi-getting-started-zephyr-mbed-tls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IMPORTANT :

As this is only a getting started project, there will be no more updates on it. However I'm currently working on a real application using Zephyr RTOS and mbedTLS (and for real) : stm32f429zi-caniot-controller

  • Branch http_async of this git is abandonned but persistent HTTP connections feature is "properly" implemented in C in the caniot-controller project.

this repo contains pictures and big O files, it is only a getting started project :)

Pages:


Nucleo f429zi

Current system model

system_model.png

Log

log_dhcp_sntp_datetime.png

UDP discovery - v1

udp_discovery_v1.png

Questions, todo & Open Points

FileSystem / MQTT CLIENT / HTTP SERVER

Get the MAC addr (can we change it ?)

See how to get a static IP, does DHCP give a rdm IP or does the MAC addr change

  • 02:80:e1:b4:be:77
  • 02:80:e1:35:7e:07

MAC address seems to change (only the 3 last bytes). The 3 first bytees stay the sames

We can fix theses values in the prj.conf file

CONFIG_ETH_STM32_HAL_RANDOM_MAC=n
CONFIG_ETH_STM32_HAL_MAC3=77
CONFIG_ETH_STM32_HAL_MAC4=77
CONFIG_ETH_STM32_HAL_MAC5=77

After mac address is not random anymore

First 3 bytes changed in NOT RANDOM MAC mode (security ? lock ?)

00:80:e1:77:77:77

Singleton - Design pattern

Choose different port than 5000 (which is DNS port)

UDP discovery, return ip, time, app name, version, and other stats

Python scapy library to test udp discovery : from scapy.all import * : send(IP(dst="192.168.10.255")/UDP(dport=5000)/Raw(load="hello"))

Interesting : Workqueues

Read : https://docs.zephyrproject.org/1.9.0/kernel/threads/workqueues.html

make it more robust

HTTP SERVER test : CONFIG_NET_BUF_POOL_USAGE

see how to use/create static variables & set class singleton, set port and other parameters

file system fs_read / fs_write

set time

efficient way to handle errors

./errors.h.png

k_work_init to sync tasks

Threading Zephyr

Zephyr Scheduling : Interesting and important : https://docs.zephyrproject.org/1.12.0/kernel/threads/scheduling.html

Polling API : https://docs.zephyrproject.org/1.9.0/kernel/other/polling.html

About main thread : https://docs.zephyrproject.org/1.12.0/kernel/threads/system_threads.html

Flash & RAM

const static uint32_t DATA[450000];  // stored in flashed
static uint32_t DATA[30000]; // stored in RAM

Info

DTS file - for hw.cpp

.dts file : nucleo_f429zi.dts located here : .platformio\packages\framework-zephyr\boards\arm\nucleo_f429zi

  • LED0, LED1, LED2 : leds green, blue, red
  • SW0 : user button

.c -> .cpp

In order to use .cpp files rather than .c files, completely delete the .pio (build) directory.

SNTP

Zephyr https://docs.zephyrproject.org/latest/reference/networking/sntp.html#group__sntp_1ga945936e5164bbd959cfa666ceacdac13

Meaning of NET_EVENT_ETHERNET_CARRIER_ON & NET_EVENT_ETHERNET_CARRIER_OFF ?

Zephyr Kernel API

https://docs.zephyrproject.org/1.9.0/api/kernel_api.html#_CPPv319k_delayed_work_initP14k_delayed_work16k_work_handler_t

Zephyr minimal configuration

  • for IoT
  • 32 bits ?
  • min 8kb on ram

Comparison Free RTOS & Zephyr RTOS & mbed os : https://www.reddit.com/r/embedded/comments/in7rjy/zephyr_vs_freertos_for_embedded_iot_project/


Issues :

Find issues in the code by typing : ISSUE 001 for example.

001. undefined reference to net_config_init_app

When disabling : CONFIG_NET_CONFIG_AUTO_INIT=n

And when we call manually net_config_init_app(NULL, "app"); or net_config_init("app", NET_CONFIG_NEED_IPV4, 1000); the linker says undefined reference to net_config_init.

Even when including #include <net/net_config.h> and all the other headers :

#include <net/net_if.h>
#include <net/net_core.h>
#include <net/net_context.h>
#include <net/net_mgmt.h>

Maybe cmake, missing binaries, configuration ?

Waiting, I'm setting CONFIG_NET_CONFIG_AUTO_INIT=y and don't calling these functions.

SOLUTION: Add CONFIG_NET_CONFIG_SETTINGS=y

002. os: CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE is 0

Need

CONFIG_LOG_BUFFER_SIZE=1024 (default)

Increase CONFIG_LOG_BUFFER_SIZE size if log message drops as following

log_message_dropped.png

About

Getting started with stm32f429zi (Nucleo f429zi) with Zephyr RTOS : Async HTTP Server, DHCP, UDP, ...

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published