Merge branch 'master' of github.com:cesanta/mongoose

This commit is contained in:
cpq committed 2023-03-30 10:50:27 +01:00
commit f4b4b41264
58 files changed
+453 -6062

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ struct mg_tcpip_spi spi = {
[](void *) { digitalWrite(SS_PIN, HIGH); }, // end transaction
[](void *, uint8_t c) { return SPI.transfer(c); }, // execute transaction
};
struct mg_tcpip_if mif = {.mac = {2, 0, 1, 2, 3, 5}}; // MIP network interface
struct mg_tcpip_if mif = {.mac = {2, 0, 1, 2, 3, 5}}; // network interface
void setup() {
Serial.begin(115200);
+2 -22
View File
@@ -1,30 +1,10 @@
# A UART to network bridge for ESP32
This example is a demonstration of how Mongoose Library could be integrated
into an embedded device and provide a UART-to-Network bridge capability:
- A device opens listening TCP port and Websocket port and waits for connections
- When a client connects, data is exchanged with the device's UART
- Everything that client send, is sent to the UART
- Everything that is read from the UART, gets sent to the client
- Multiple clients are allowed
- Live UART console allows to talk to the UART from the web page
- Web UI is hardcoded into the binary and does not need a filesystem
# Screenshots
![](../../uart-bridge/screenshots/dashboard.png)
# Build and flash
- See detailed tutorial at https://mongoose.ws/tutorials/esp32/uart-bridge/
Build requires Docker installed, and uses Espressif's ESP-IDF docker image:
```sh
make build
make flash PORT=/dev/YOURSERIAL
```
# Flash pre-built firmware
## Flash pre-built firmware
You can flash a pre-built firmware to the ESP32 device using the following
instructions:
+1 -22
View File
@@ -1,22 +1 @@
# An example ESP8266 application
To build this application, follow these steps:
1. Make sure you have Docker installed
2. Clone whole mongoose repository on your machine:
```sh
git clone https://github.com/cesanta/mongoose.git
```
3. Start command line or terminal, and go into the example's directory:
```sh
cd mongoose/examples/esp8266
```
4. Run `make`. This invokes a Docker-based build. A firmware will be built
in the `src/build/` directory:
```sh
make build
```
5. Flash your ESP8266. If you have esptool.py installed, the build process will end telling you the command to flash your device. You can just run `make` again to use Docker:
```sh
make flash PORT=/your/serial
```
See detailed tutorial at https://mongoose.ws/tutorials/esp8266/http-client-server/
+2 -2
View File
@@ -24,10 +24,10 @@ int main(void) {
stdio_init_all();
struct mg_mgr mgr; // Initialise Mongoose event manager
mg_mgr_init(&mgr); // and attach it to the MIP interface
mg_mgr_init(&mgr); // and attach it to the interface
mg_log_set(MG_LL_DEBUG); // Set log level
MG_INFO(("Init MIP"));
MG_INFO(("Init TCP/IP"));
// Initialise Mongoose network stack and specific driver
// Set consecutive GPIOs for RMII (tx and rx) and SMI function groups
struct mg_tcpip_driver_rp2040_rmii_data driver_data = {
+1 -1
View File
@@ -53,7 +53,7 @@ int main(void) {
stdio_init_all();
struct mg_mgr mgr; // Initialise Mongoose event manager
mg_mgr_init(&mgr); // and attach it to the MIP interface
mg_mgr_init(&mgr); // and attach it to the interface
mg_timer_add(&mgr, 500, MG_TIMER_REPEAT, blink_cb, &mgr);
struct mg_tcpip_driver driver = {.tx = usb_tx, .up = usb_up};
+39 -22
View File
@@ -6,6 +6,7 @@
#include "hardware/spi.h"
#include "pico/rand.h"
#include "pico/stdlib.h"
#include "pico/unique_id.h"
#include "mongoose.h"
@@ -31,42 +32,58 @@ void mg_random(void *buf, size_t len) {
}
}
static void timer_cb(void *arg) {
gpio_put(PICO_DEFAULT_LED_PIN, !gpio_get_out_level(PICO_DEFAULT_LED_PIN));
bool up = ((struct mg_tcpip_if *) arg)->state == MIP_STATE_READY;
MG_INFO(("Ethernet: %s", up ? "up" : "down")); // Show network status
static void timer_fn(void *arg) {
gpio_put(PICO_DEFAULT_LED_PIN,
!gpio_get_out_level(PICO_DEFAULT_LED_PIN)); // Blink LED
struct mg_tcpip_if *ifp = arg; // And show
const char *names[] = {"down", "up", "ready"}; // network stats
MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u",
names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent,
ifp->ndrop, ifp->nerr));
}
int main(void) {
stdio_init_all();
MG_INFO(("Starting ..."));
// Init LED
gpio_init(LED);
gpio_set_dir(LED, GPIO_OUT);
static void eth_spi_init(void) {
// Init SPI pins
spi_init(spi0, 500 * 1000);
gpio_set_function(SPI_RX, GPIO_FUNC_SPI); // MISO
gpio_set_function(SPI_TX, GPIO_FUNC_SPI); // MOSI
gpio_set_function(SPI_CLK, GPIO_FUNC_SPI); // CLK
gpio_init(SPI_CS); // CS
gpio_set_dir(SPI_CS, GPIO_OUT); // Set CS it to output
gpio_set_dir(SPI_CS, GPIO_OUT); // Set CS to output
gpio_put(SPI_CS, 1); // And drive CS high (inactive)
}
// Init Mongoose
// Helper macro for MAC generation
#define GENERATE_LOCALLY_ADMINISTERED_MAC(id) \
{ 2, id[3], id[4], id[5], id[6], id[7] }
int main(void) {
stdio_init_all();
gpio_init(LED); // Setup board LED
gpio_set_dir(LED, GPIO_OUT);
eth_spi_init(); // Initialise SPI pins
MG_INFO(("Starting ..."));
pico_unique_board_id_t board_id;
pico_get_unique_board_id(&board_id);
uint8_t *id = board_id.id;
struct mg_mgr mgr; // Initialise
mg_mgr_init(&mgr); // Mongoose event manager
mg_log_set(MG_LL_DEBUG); // Set log level
// Initialise Mongoose network stack
// Specify MAC address, and IP/mask/GW in network byte order for static
// IP configuration. If IP/mask/GW are unset, DHCP is going to be used
struct mg_tcpip_spi spi = {NULL, spi_begin, spi_end, spi_txn};
struct mg_tcpip_if mif = {.mac = {2, 0, 1, 2, 3, 5},
struct mg_tcpip_if mif = {.mac = GENERATE_LOCALLY_ADMINISTERED_MAC(id),
.driver = &mg_tcpip_driver_w5500,
.driver_data = &spi};
struct mg_mgr mgr; // Declare event manager
mg_mgr_init(&mgr); // Init event manager
mg_log_set(MG_LL_DEBUG); // Set DEBUG log level
mg_tcpip_init(&mgr, &mif); // Init TCP/IP stack
mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_cb, &mif);
mg_tcpip_init(&mgr, &mif);
mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif);
MG_INFO(("Waiting until network is up..."));
while (mif.state != MIP_STATE_READY) {
MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac));
while (mif.state != MG_TCPIP_STATE_READY) {
mg_mgr_poll(&mgr, 0);
}
@@ -73,7 +73,7 @@ int main(void) {
mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif);
MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac));
while (mif.state != MIP_STATE_READY) {
while (mif.state != MG_TCPIP_STATE_READY) {
mg_mgr_poll(&mgr, 0);
}
+2 -2
View File
@@ -45,7 +45,7 @@ static void ethernet_init(void) {
static void server(void *args) {
struct mg_mgr mgr; // Initialise Mongoose event manager
mg_mgr_init(&mgr); // and attach it to the MIP interface
mg_mgr_init(&mgr); // and attach it to the interface
mg_log_set(MG_LL_DEBUG); // Set log level
// Initialise Mongoose network stack
@@ -60,7 +60,7 @@ static void server(void *args) {
mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif);
MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac));
while (mif.state != MIP_STATE_READY) {
while (mif.state != MG_TCPIP_STATE_READY) {
mg_mgr_poll(&mgr, 0);
}
@@ -1,7 +1,5 @@
#pragma once
#include <errno.h> // we are not using lwIP
// See https://mongoose.ws/documentation/#build-options
#define MG_ARCH MG_ARCH_FREERTOS
#define MG_ENABLE_TCPIP 1
@@ -73,7 +73,7 @@ int main(void) {
mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif);
MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac));
while (mif.state != MIP_STATE_READY) {
while (mif.state != MG_TCPIP_STATE_READY) {
mg_mgr_poll(&mgr, 0);
}
+2 -2
View File
@@ -45,7 +45,7 @@ static void ethernet_init(void) {
static void server(void *args) {
struct mg_mgr mgr; // Initialise Mongoose event manager
mg_mgr_init(&mgr); // and attach it to the MIP interface
mg_mgr_init(&mgr); // and attach it to the interface
mg_log_set(MG_LL_DEBUG); // Set log level
// Initialise Mongoose network stack
@@ -60,7 +60,7 @@ static void server(void *args) {
mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif);
MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac));
while (mif.state != MIP_STATE_READY) {
while (mif.state != MG_TCPIP_STATE_READY) {
mg_mgr_poll(&mgr, 0);
}
@@ -1,7 +1,5 @@
#pragma once
#include <errno.h> // we are not using lwIP
// See https://mongoose.ws/documentation/#build-options
#define MG_ARCH MG_ARCH_FREERTOS
#define MG_ENABLE_TCPIP 1
@@ -8,7 +8,7 @@ LDFLAGS ?= -Tlink.ld -nostdlib -nostartfiles --specs nano.specs -lc -lgcc -Wl,--
SOURCES = main.c syscalls.c sysinit.c
SOURCES += cmsis_h7/Source/Templates/gcc/startup_stm32h743xx.s # ST startup file. Compiler-dependent!
# Mongoose-specific source code files and build options. See https://mongoose.ws/documentation/#build-options
# Mongoose-specific. See https://mongoose.ws/documentation/#build-options
SOURCES += mongoose.c net.c packed_fs.c
CFLAGS += -DMG_ENABLE_TCPIP=1 -DMG_ARCH=MG_ARCH_NEWLIB -DMG_ENABLE_PACKED_FS=1
CFLAGS += -DMG_ENABLE_CUSTOM_RANDOM=1 -DMG_ENABLE_CUSTOM_MILLIS=1
@@ -41,11 +41,11 @@ DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/6
update: firmware.bin
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/ota --data-binary @$<
update test: CFLAGS_EXTRA += -DUART_DEBUG=USART1
test update: CFLAGS_EXTRA += -DUART_DEBUG=USART1
test: update
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 | tee /tmp/output.txt
grep 'READY, IP:' /tmp/output.txt # Check for network init
grep 'MQTT connected' /tmp/output.txt # Check for MQTT connection success
clean:
@rm -rf firmware.* *.su cmsis_core cmsis_h7
$(RM) firmware.* *.su cmsis_core cmsis_h7
@@ -75,7 +75,7 @@ int main(void) {
mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif);
MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac));
while (mif.state != MIP_STATE_READY) {
while (mif.state != MG_TCPIP_STATE_READY) {
mg_mgr_poll(&mgr, 0);
}
+2 -2
View File
@@ -40,11 +40,11 @@ DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/1
update: firmware.bin
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/ota --data-binary @$<
test update: CFLAGS_EXTRA += -DUART_DEBUG=UART1
test update: CFLAGS_EXTRA += -DUART_DEBUG=UART0
test: update
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 | tee /tmp/output.txt
grep 'READY, IP:' /tmp/output.txt # Check for network init
grep 'MQTT connected' /tmp/output.txt # Check for MQTT connection success
# grep 'MQTT connected' /tmp/output.txt # Check for MQTT connection success
clean:
$(RM) firmware.* *.su cmsis_core cmsis_tm4c
+1 -47
View File
@@ -1,47 +1 @@
# Baremetal webserver on EK-TM4C1294XL
This firmware uses experimental TCP/IP stack of the Mongoose Network Library,
which implements the following:
- A complete [HTTP device dashboard](../../device-dashboard) with:
- User authentication
- Real-time device data graph
- Coninfiguration display and update
- MQTT communication with a remote MQTT server
- No dependencies: no HAL, no CMSIS, no RTOS
- Hand-written [mcu.h](mcu.h) header based on the [datasheet](https://www.ti.com/lit/pdf/spms433)
- Interrupt-driven Ethernet driver
- LED blinky, based on SysTick interrupt
- User button handler, turns off/on an LED, based on GPIO IRQs (interrupt-driven)
- HardFault handler alternate blinks LEDs
- Debug log on UART0 (ICDI)
## Requirements
- [GNU make](http://mongoose.ws/tutorials/tools/#gnu-make)
- [ARM GCC](http://mongoose.ws/tutorials/tools/#arm-gcc)
- [Uniflash](https://mongoose.ws/tutorials/ti/ek-tm4c1294xl-baremetal/#build-and-run) for flashing
The links above will send you to tutorials on how to install each of those tools in your workstation for Linux, Mac, and Windows.
## Usage
Plugin your board into USB, and attach an Ethernet cable.
To build:
```sh
$ make clean build
```
To flash: use Uniflash
To see debug log, use any serial monitor program like `picocom` at 115200 bps and configure it to insert carriage returns after line feeds:
```sh
$ picocom /dev/ttyACM0 -i -b 115200 --imap=lfcrlf
```
There is also a [detailed tutorial on this example](https://mongoose.ws/tutorials/ti/ek-tm4c1294xl-baremetal/)
For more details and benchmark data on MIP, check the [F746ZG example](../../stm32/nucleo-f746zg-baremetal/)
See detailed tutorial at https://mongoose.ws/tutorials/ti/ek-tm4c1294xl-baremetal/
+9 -13
View File
@@ -133,22 +133,18 @@ static inline void gpio_irq_attach(uint16_t pin) {
#define UARTNO(u) ((uint8_t) (((unsigned int) (u) -UART0_BASE) / UART_OFFSET))
static inline void uart_init(UART0_Type *uart, unsigned long baud) {
struct uarthw {
uint16_t rx, tx; // pins
uint8_t af; // Alternate function
};
// rx, tx, af for UART0,1,2
struct uarthw uarthw[3] = {{PIN('A', 0), PIN('A', 1), 1},
{PIN('B', 0), PIN('B', 1), 1},
{PIN('A', 6), PIN('A', 7), 1}}; // or PD4, PD5...
uint8_t af = 1; // Alternate function
uint16_t rx = 0, tx = 0; // pins
uint8_t uartno = UARTNO(uart);
SYSCTL->RCGCUART |= BIT(uartno); // Enable peripheral clock
gpio_init(uarthw[uartno].tx, GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL,
GPIO_SPEED_HIGH, 0, uarthw[uartno].af);
gpio_init(uarthw[uartno].rx, GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL,
GPIO_SPEED_HIGH, 0, uarthw[uartno].af);
if (uart == UART0) tx = PIN('A', 0), rx = PIN('A', 1);
if (uart == UART1) tx = PIN('B', 0), rx = PIN('B', 1);
if (uart == UART2) tx = PIN('A', 6), rx = PIN('A', 7); // or PD4, PD5...
gpio_init(tx, GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, 0, af);
gpio_init(rx, GPIO_MODE_AF, GPIO_OTYPE_PUSH_PULL, GPIO_SPEED_HIGH, 0, af);
// (16.3.2) ClkDiv = 16 (HSE=0)
// BRD = BRDI + BRDF = UARTSysClk / (ClkDiv * Baud Rate)
// UARTFBRD[DIVFRAC] = integer(BRDF * 64 + 0.5)
+1 -1
View File
@@ -84,7 +84,7 @@ int main(void) {
mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif);
MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac));
while (mif.state != MIP_STATE_READY) {
while (mif.state != MG_TCPIP_STATE_READY) {
mg_mgr_poll(&mgr, 0);
}
+2 -2
View File
@@ -46,11 +46,11 @@ DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/1
update: firmware.bin
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/ota --data-binary @$<
test update: CFLAGS_EXTRA += -DUART_DEBUG=UART1
test update: CFLAGS_EXTRA += -DUART_DEBUG=UART0
test: update
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 | tee /tmp/output.txt
grep 'READY, IP:' /tmp/output.txt # Check for network init
grep 'MQTT connected' /tmp/output.txt # Check for MQTT connection success
# grep 'MQTT connected' /tmp/output.txt # Check for MQTT connection success
clean:
$(RM) firmware.* *.su cmsis_core cmsis_tm4c FreeRTOS-Kernel
+2 -2
View File
@@ -48,7 +48,7 @@ static void ethernet_init(void) {
static void server(void *args) {
struct mg_mgr mgr; // Initialise Mongoose event manager
mg_mgr_init(&mgr); // and attach it to the MIP interface
mg_mgr_init(&mgr); // and attach it to the interface
mg_log_set(MG_LL_DEBUG); // Set log level
// Initialise Mongoose network stack
@@ -69,7 +69,7 @@ static void server(void *args) {
mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif);
MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac));
while (mif.state != MIP_STATE_READY) {
while (mif.state != MG_TCPIP_STATE_READY) {
mg_mgr_poll(&mgr, 0);
}
@@ -1,7 +1,5 @@
#pragma once
#include <errno.h> // we are not using lwIP
// See https://mongoose.ws/documentation/#build-options
#define MG_ARCH MG_ARCH_FREERTOS
#define MG_ENABLE_TCPIP 1
+8 -17
View File
@@ -1,24 +1,15 @@
# Zephyr Project examples
## Building
- See detailed tutorial at https://mongoose.ws/tutorials/zephyr/device-dashboard/
- Run `make zephyr`, this will clone the Zephyr Project repo or update it if you've already done it before
- Now you can build the project, follow one of this options:
The tutorial is specific for the Device Dashboard example but [build instructions](https://mongoose.ws/tutorials/zephyr/device-dashboard/#build-and-run) are generic
### Trying on a simulated board
The default board is an x86 machine that can be simulated with QEMU, and runs inside a _Docker_ container, you only need to have _Docker_ installed. Its Ethernet is also simulated and uses the TUN/TAP interface.
You'll need a TUN/TAP interface (default name is _tap0_) on your host machine; follow the instructions [here](https://github.com/cesanta/mongoose/tree/master/examples/mip-tap#linux-setup) to configure your network to provide a suitable networking environment.
- Run `make build`. The interface configuration on the simulated machine side is in the file _overlay-e1000.conf_, and defaults to _tap0_. You can change this overlay file adding an `OVERLAY` argument (e.g.: *make build OVERLAY="-DOVERLAY_CONFIG=something"*).
- Once the build succeeds, run `make run` to run the target. The default _Docker_ configuration is to share _/dev/net/tun_; if this does not work for you, pass the necessary _Docker_ parameters inside `SHARETUN` (e.g.: *make run SHARETUN=something*).
## Optional: Using a simulated board
### Using a real board
For testing purposes, we build for an x86 target that can be simulated with QEMU, and runs inside a _Docker_ container. Its Ethernet interface is also simulated, and uses the TUN/TAP interface. You can use this to try the examples or for your own development with Zephyr, without the need to have an actual board connected; you only need to have _Docker_ installed as the Zephyr Docker image handles the emulation for you.
- Run `make build BOARD=yourboardname` (e.g.: *make build BOARD=nucleo_f746zg*)
- Once the build succeeds, run `make flash`. The Makefile shares the USB bus with the _Docker_ container, this works well with ST-Link and J-Link devices. If this does not work for you, pass the necessary _Docker_ parameters inside `SHAREUSB` (e.g.: *make flash SHAREUSB=something*)
- The generated ELF file is at _build/zephyr_
## Cleaning up
- You can run `make clean` to clean up the build files but keep the configuration files, which speeds the next build
- If you do major changes (like compiling for a different board...), run `make pristine` to clean up everything under the _build_ directory.
- You'll need a TUN/TAP interface (default name is _tap0_) on your host machine; follow the instructions [here](https://github.com/cesanta/mongoose/tree/master/examples/mip-tap#linux-setup) to configure your network to provide a suitable networking environment.
- Run `make build BUILD_ARGS="-b qemu_x86" OVERLAY="-DOVERLAY_CONFIG=overlay-e1000.conf"`.
- The interface configuration on the simulated machine side is in the file _overlay-e1000.conf_, and defaults to _tap0_. You can change this file or specify a different one by changing the `OVERLAY_CONFIG` argument above.
- Once the build succeeds, run `make run` to run the target. The default _Docker_ configuration is to share _/dev/net/tun_; if this does not work for you, pass the necessary _Docker_ parameters to _make_ with a `DOCKER_ARGS=` argument.
+30 -45
View File
@@ -1,61 +1,46 @@
MONGOOSE_ROOT ?= $(realpath $(CURDIR)/../../..)
DOCKER_PROJECT_DIR ?= /workdir
ZEPHYR_DIR ?= zephyrproject
PROJECT_NAME = $(notdir $(CURDIR))
PROJECT_PATH = $(realpath $(CURDIR))
ZEPHYR_PATH = $(realpath $(CURDIR)/..)/$(ZEPHYR_DIR)
DOCKER_PROJECT_PATH = $(DOCKER_PROJECT_DIR)/$(PROJECT_NAME)
DOCKER_ZEPHYR_PATH = $(DOCKER_PROJECT_DIR)/$(ZEPHYR_DIR)
BOARD ?= qemu_x86
ifeq "$(BOARD)" "qemu_x86"
OVERLAY ?= -DOVERLAY_CONFIG=overlay-e1000.conf
else
OVERLAY ?=
endif
SHAREUSB ?= --privileged -v /dev/bus/usb/:/dev/bus/usb
SHARETUN ?= --cap-add=NET_ADMIN --device /dev/net/tun --net=host
DOCKER ?= docker run --rm -v $(PROJECT_PATH):$(DOCKER_PROJECT_PATH) -v $(ZEPHYR_PATH):$(DOCKER_ZEPHYR_PATH)
REPO ?= zephyrprojectrtos/ci
TOP_DIR ?= $(realpath $(CURDIR)/../../..)
ZEPHYR_DIR ?= $(realpath $(CURDIR)/..)/zephyrproject
DOCKER ?= docker run --rm \
-v $(TOP_DIR):$(TOP_DIR) \
-w $(realpath $(CURDIR)) \
-e ZEPHYR_BASE=$(ZEPHYR_DIR)/zephyr \
$(DOCKER_ARGS) zephyrprojectrtos/ci
BUILD_ARGS ?= -b nucleo_f746zg
.PHONY: build
example:
true
build:
cp $(MONGOOSE_ROOT)/mongoose.[ch] src/
cp $(MONGOOSE_ROOT)/examples/device-dashboard/net.c src/
cp $(MONGOOSE_ROOT)/examples/device-dashboard/packed_fs.c src/
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH)/zephyr && \
west build -b $(BOARD) -p auto $(DOCKER_PROJECT_PATH) $(OVERLAY) --build-dir $(DOCKER_PROJECT_PATH)/build'
zephyr:
test -d $(ZEPHYR_DIR) || ( mkdir -p $(ZEPHYR_DIR) ; $(DOCKER) west init $(ZEPHYR_DIR))
$(DOCKER) sh -c 'cd $(ZEPHYR_DIR) && west update'
build:
cp $(TOP_DIR)/mongoose.[ch] src/
cp $(TOP_DIR)/examples/device-dashboard/net.c src/
cp $(TOP_DIR)/examples/device-dashboard/packed_fs.c src/
$(DOCKER) west build $(BUILD_ARGS) -p auto $(realpath $(CURDIR)) $(OVERLAY)
run: DOCKER_ARGS ?= --cap-add=NET_ADMIN --device /dev/net/tun --net=host -it
run:
$(DOCKER) -it $(SHARETUN) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t run --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west build -t run
clean:
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t clean --build-dir $(DOCKER_PROJECT_PATH)/build'
-$(DOCKER) west build -t clean
pristine:
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t pristine --build-dir $(DOCKER_PROJECT_PATH)/build'
-$(DOCKER) west build -t pristine
purge: clean pristine
rm -rf $(TOP_DIR)/.west $(ZEPHYR_DIR) build
flash debug: DOCKER_ARGS ?= --privileged -v /dev/bus/usb/:/dev/bus/usb -it
flash:
$(DOCKER) $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west flash --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west flash --build-dir $(realpath $(CURDIR))/build
debug:
$(DOCKER) -it $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west debug --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west debug --build-dir $(realpath $(CURDIR))/build
.PHONY: build flash zephyr clean pristine run
zephyr:
ifeq ($(wildcard $(ZEPHYR_PATH)/.*),)
mkdir $(ZEPHYR_PATH)
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_PROJECT_DIR) && west init ./$(ZEPHYR_DIR)'
endif
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && west update'
test: BUILD_ARGS = -b qemu_x86
test: OVERLAY = -DOVERLAY_CONFIG=overlay-e1000.conf
test: build run
+6 -3
View File
@@ -5,8 +5,7 @@ DOCKER ?= docker run --rm \
-w $(realpath $(CURDIR)) \
-e ZEPHYR_BASE=$(ZEPHYR_DIR)/zephyr \
$(DOCKER_ARGS) zephyrprojectrtos/ci
#BUILD_ARGS ?= -b qemu_x86 -DOVERLAY_CONFIG=overlay-e1000.conf
BUILD_ARGS ?= -b nucleo_f429zi
BUILD_ARGS ?= -b nucleo_f746zg
.PHONY: build
example:
@@ -18,7 +17,7 @@ zephyr:
build:
cp $(TOP_DIR)/mongoose.[ch] src/
$(DOCKER) west build $(BUILD_ARGS) -p auto $(realpath $(CURDIR))
$(DOCKER) west build $(BUILD_ARGS) -p auto $(realpath $(CURDIR)) $(OVERLAY)
run: DOCKER_ARGS ?= --cap-add=NET_ADMIN --device /dev/net/tun --net=host -it
run:
@@ -39,3 +38,7 @@ flash:
debug:
$(DOCKER) west debug --build-dir $(realpath $(CURDIR))/build
test: BUILD_ARGS = -b qemu_x86
test: OVERLAY = -DOVERLAY_CONFIG=overlay-e1000.conf
test: build run
+28 -43
View File
@@ -1,59 +1,44 @@
MONGOOSE_ROOT ?= $(realpath $(CURDIR)/../../..)
DOCKER_PROJECT_DIR ?= /workdir
ZEPHYR_DIR ?= zephyrproject
PROJECT_NAME = $(notdir $(CURDIR))
PROJECT_PATH = $(realpath $(CURDIR))
ZEPHYR_PATH = $(realpath $(CURDIR)/..)/$(ZEPHYR_DIR)
DOCKER_PROJECT_PATH = $(DOCKER_PROJECT_DIR)/$(PROJECT_NAME)
DOCKER_ZEPHYR_PATH = $(DOCKER_PROJECT_DIR)/$(ZEPHYR_DIR)
BOARD ?= qemu_x86
ifeq "$(BOARD)" "qemu_x86"
OVERLAY ?= -DOVERLAY_CONFIG=overlay-e1000.conf
else
OVERLAY ?=
endif
SHAREUSB ?= --privileged -v /dev/bus/usb/:/dev/bus/usb
SHARETUN ?= --cap-add=NET_ADMIN --device /dev/net/tun --net=host
DOCKER ?= docker run --rm -v $(PROJECT_PATH):$(DOCKER_PROJECT_PATH) -v $(ZEPHYR_PATH):$(DOCKER_ZEPHYR_PATH)
REPO ?= zephyrprojectrtos/ci
TOP_DIR ?= $(realpath $(CURDIR)/../../..)
ZEPHYR_DIR ?= $(realpath $(CURDIR)/..)/zephyrproject
DOCKER ?= docker run --rm \
-v $(TOP_DIR):$(TOP_DIR) \
-w $(realpath $(CURDIR)) \
-e ZEPHYR_BASE=$(ZEPHYR_DIR)/zephyr \
$(DOCKER_ARGS) zephyrprojectrtos/ci
BUILD_ARGS ?= -b nucleo_f746zg
.PHONY: build
example:
true
build:
cp $(MONGOOSE_ROOT)/mongoose.[ch] src/
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH)/zephyr && \
west build -b $(BOARD) -p auto $(DOCKER_PROJECT_PATH) $(OVERLAY) --build-dir $(DOCKER_PROJECT_PATH)/build'
zephyr:
test -d $(ZEPHYR_DIR) || ( mkdir -p $(ZEPHYR_DIR) ; $(DOCKER) west init $(ZEPHYR_DIR))
$(DOCKER) sh -c 'cd $(ZEPHYR_DIR) && west update'
build:
cp $(TOP_DIR)/mongoose.[ch] src/
$(DOCKER) west build $(BUILD_ARGS) -p auto $(realpath $(CURDIR)) $(OVERLAY)
run: DOCKER_ARGS ?= --cap-add=NET_ADMIN --device /dev/net/tun --net=host -it
run:
$(DOCKER) -it $(SHARETUN) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t run --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west build -t run
clean:
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t clean --build-dir $(DOCKER_PROJECT_PATH)/build'
-$(DOCKER) west build -t clean
pristine:
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t pristine --build-dir $(DOCKER_PROJECT_PATH)/build'
-$(DOCKER) west build -t pristine
purge: clean pristine
rm -rf $(TOP_DIR)/.west $(ZEPHYR_DIR) build
flash debug: DOCKER_ARGS ?= --privileged -v /dev/bus/usb/:/dev/bus/usb -it
flash:
$(DOCKER) $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west flash --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west flash --build-dir $(realpath $(CURDIR))/build
debug:
$(DOCKER) -it $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west debug --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west debug --build-dir $(realpath $(CURDIR))/build
.PHONY: build flash zephyr clean pristine run
zephyr:
ifeq ($(wildcard $(ZEPHYR_PATH)/.*),)
mkdir $(ZEPHYR_PATH)
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_PROJECT_DIR) && west init ./$(ZEPHYR_DIR)'
endif
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && west update'
test: BUILD_ARGS = -b qemu_x86
test: OVERLAY = -DOVERLAY_CONFIG=overlay-e1000.conf
test: build run
+28 -43
View File
@@ -1,59 +1,44 @@
MONGOOSE_ROOT ?= $(realpath $(CURDIR)/../../..)
DOCKER_PROJECT_DIR ?= /workdir
ZEPHYR_DIR ?= zephyrproject
PROJECT_NAME = $(notdir $(CURDIR))
PROJECT_PATH = $(realpath $(CURDIR))
ZEPHYR_PATH = $(realpath $(CURDIR)/..)/$(ZEPHYR_DIR)
DOCKER_PROJECT_PATH = $(DOCKER_PROJECT_DIR)/$(PROJECT_NAME)
DOCKER_ZEPHYR_PATH = $(DOCKER_PROJECT_DIR)/$(ZEPHYR_DIR)
BOARD ?= qemu_x86
ifeq "$(BOARD)" "qemu_x86"
OVERLAY ?= -DOVERLAY_CONFIG=overlay-e1000.conf
else
OVERLAY ?=
endif
SHAREUSB ?= --privileged -v /dev/bus/usb/:/dev/bus/usb
SHARETUN ?= --cap-add=NET_ADMIN --device /dev/net/tun --net=host
DOCKER ?= docker run --rm -v $(PROJECT_PATH):$(DOCKER_PROJECT_PATH) -v $(ZEPHYR_PATH):$(DOCKER_ZEPHYR_PATH)
REPO ?= zephyrprojectrtos/ci
TOP_DIR ?= $(realpath $(CURDIR)/../../..)
ZEPHYR_DIR ?= $(realpath $(CURDIR)/..)/zephyrproject
DOCKER ?= docker run --rm \
-v $(TOP_DIR):$(TOP_DIR) \
-w $(realpath $(CURDIR)) \
-e ZEPHYR_BASE=$(ZEPHYR_DIR)/zephyr \
$(DOCKER_ARGS) zephyrprojectrtos/ci
BUILD_ARGS ?= -b nucleo_f746zg
.PHONY: build
example:
true
build:
cp $(MONGOOSE_ROOT)/mongoose.[ch] src/
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH)/zephyr && \
west build -b $(BOARD) -p auto $(DOCKER_PROJECT_PATH) $(OVERLAY) --build-dir $(DOCKER_PROJECT_PATH)/build'
zephyr:
test -d $(ZEPHYR_DIR) || ( mkdir -p $(ZEPHYR_DIR) ; $(DOCKER) west init $(ZEPHYR_DIR))
$(DOCKER) sh -c 'cd $(ZEPHYR_DIR) && west update'
build:
cp $(TOP_DIR)/mongoose.[ch] src/
$(DOCKER) west build $(BUILD_ARGS) -p auto $(realpath $(CURDIR)) $(OVERLAY)
run: DOCKER_ARGS ?= --cap-add=NET_ADMIN --device /dev/net/tun --net=host -it
run:
$(DOCKER) -it $(SHARETUN) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t run --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west build -t run
clean:
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t clean --build-dir $(DOCKER_PROJECT_PATH)/build'
-$(DOCKER) west build -t clean
pristine:
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t pristine --build-dir $(DOCKER_PROJECT_PATH)/build'
-$(DOCKER) west build -t pristine
purge: clean pristine
rm -rf $(TOP_DIR)/.west $(ZEPHYR_DIR) build
flash debug: DOCKER_ARGS ?= --privileged -v /dev/bus/usb/:/dev/bus/usb -it
flash:
$(DOCKER) $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west flash --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west flash --build-dir $(realpath $(CURDIR))/build
debug:
$(DOCKER) -it $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west debug --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west debug --build-dir $(realpath $(CURDIR))/build
.PHONY: build flash zephyr clean pristine run
zephyr:
ifeq ($(wildcard $(ZEPHYR_PATH)/.*),)
mkdir $(ZEPHYR_PATH)
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_PROJECT_DIR) && west init ./$(ZEPHYR_DIR)'
endif
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && west update'
test: BUILD_ARGS = -b qemu_x86
test: OVERLAY = -DOVERLAY_CONFIG=overlay-e1000.conf
test: build run
+28 -43
View File
@@ -1,59 +1,44 @@
MONGOOSE_ROOT ?= $(realpath $(CURDIR)/../../..)
DOCKER_PROJECT_DIR ?= /workdir
ZEPHYR_DIR ?= zephyrproject
PROJECT_NAME = $(notdir $(CURDIR))
PROJECT_PATH = $(realpath $(CURDIR))
ZEPHYR_PATH = $(realpath $(CURDIR)/..)/$(ZEPHYR_DIR)
DOCKER_PROJECT_PATH = $(DOCKER_PROJECT_DIR)/$(PROJECT_NAME)
DOCKER_ZEPHYR_PATH = $(DOCKER_PROJECT_DIR)/$(ZEPHYR_DIR)
BOARD ?= qemu_x86
ifeq "$(BOARD)" "qemu_x86"
OVERLAY ?= -DOVERLAY_CONFIG=overlay-e1000.conf
else
OVERLAY ?=
endif
SHAREUSB ?= --privileged -v /dev/bus/usb/:/dev/bus/usb
SHARETUN ?= --cap-add=NET_ADMIN --device /dev/net/tun --net=host
DOCKER ?= docker run --rm -v $(PROJECT_PATH):$(DOCKER_PROJECT_PATH) -v $(ZEPHYR_PATH):$(DOCKER_ZEPHYR_PATH)
REPO ?= zephyrprojectrtos/ci
TOP_DIR ?= $(realpath $(CURDIR)/../../..)
ZEPHYR_DIR ?= $(realpath $(CURDIR)/..)/zephyrproject
DOCKER ?= docker run --rm \
-v $(TOP_DIR):$(TOP_DIR) \
-w $(realpath $(CURDIR)) \
-e ZEPHYR_BASE=$(ZEPHYR_DIR)/zephyr \
$(DOCKER_ARGS) zephyrprojectrtos/ci
BUILD_ARGS ?= -b nucleo_f746zg
.PHONY: build
example:
true
build:
cp $(MONGOOSE_ROOT)/mongoose.[ch] src/
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH)/zephyr && \
west build -b $(BOARD) -p auto $(DOCKER_PROJECT_PATH) $(OVERLAY) --build-dir $(DOCKER_PROJECT_PATH)/build'
zephyr:
test -d $(ZEPHYR_DIR) || ( mkdir -p $(ZEPHYR_DIR) ; $(DOCKER) west init $(ZEPHYR_DIR))
$(DOCKER) sh -c 'cd $(ZEPHYR_DIR) && west update'
build:
cp $(TOP_DIR)/mongoose.[ch] src/
$(DOCKER) west build $(BUILD_ARGS) -p auto $(realpath $(CURDIR)) $(OVERLAY)
run: DOCKER_ARGS ?= --cap-add=NET_ADMIN --device /dev/net/tun --net=host -it
run:
$(DOCKER) -it $(SHARETUN) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t run --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west build -t run
clean:
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t clean --build-dir $(DOCKER_PROJECT_PATH)/build'
-$(DOCKER) west build -t clean
pristine:
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west build -t pristine --build-dir $(DOCKER_PROJECT_PATH)/build'
-$(DOCKER) west build -t pristine
purge: clean pristine
rm -rf $(TOP_DIR)/.west $(ZEPHYR_DIR) build
flash debug: DOCKER_ARGS ?= --privileged -v /dev/bus/usb/:/dev/bus/usb -it
flash:
$(DOCKER) $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west flash --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west flash --build-dir $(realpath $(CURDIR))/build
debug:
$(DOCKER) -it $(SHAREUSB) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && \
west debug --build-dir $(DOCKER_PROJECT_PATH)/build'
$(DOCKER) west debug --build-dir $(realpath $(CURDIR))/build
.PHONY: build flash zephyr clean pristine run
zephyr:
ifeq ($(wildcard $(ZEPHYR_PATH)/.*),)
mkdir $(ZEPHYR_PATH)
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_PROJECT_DIR) && west init ./$(ZEPHYR_DIR)'
endif
$(DOCKER) $(REPO) /bin/sh -c 'cd $(DOCKER_ZEPHYR_PATH) && west update'
test: BUILD_ARGS = -b qemu_x86
test: OVERLAY = -DOVERLAY_CONFIG=overlay-e1000.conf
test: build run