Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

Changelog

Version

Date

Remark

1.0

Initial Release

1.1

15.02.2021

Fixed msys installation procedure

Table: Changelog

Introduction

Scope

This document describes the the project generator for application projects.
Beside that the generator for the GOAL web server is described.

Document structure

Chapter

Content

Introduction

Introduction of this document

Project creation

Introduction to GOAL projects

Installation

Installation requirements for the generators

Project generator

Description of the GOAL project generator

HTTP generator

Description of the GOAL http generator

Table: Content of this document

GOAL projects

GOAL projects consist of a Makefile and are build using the make utility.
Changes regarding features or files need to be done within the project
Makefile.

Following an example project file:

## @file
#
# @brief
# Generic Makefile
#
# The output will be stored in the directory build/.
#
# @copyright
# Copyright 2020 port GmbH Halle/Saale.
# This software is protected Intellectual Property and may only be used
# according to the license agreement.
#


# paths
PWD = $(shell pwd)
GOAL = $(PWD)/../../../../..
APPL = appl/2015013_irj45/ac/09_ecat_slave
TGTS = $(PWD)/targets

# features
CONFIG_MAKE_FEAT_MCTC_AC = 1
CONFIG_MAKE_FEAT_GOAL_ECAT = 1
CONFIG_MAKE_FEAT_DD_CTC_AC = 1
CONFIG_MAKE_FEAT_LM_EMIT_MA_UART = 1
CONFIG_MAKE_FEAT_HTTP = 1

# files
SRC_C += \
    $(APPL)/goal_appl.c \
    $(APPL)/../../rpc/ccm_rpc_ac.c \
    $(APPL)/goal_appl_ecat.c \
    $(APPL)/goal_appl_ecat_objects.c \
    $(APPL)/goal_appl_foe.c \
    $(APPL)/goal_appl_http.c

INC_C_FILES += \
    $(APPL)/../../rpc/ccm_rpc_ac.h \
    $(APPL)/../../rpc/ccm_rpc.h \
    $(APPL)/goal_appl_ecat.h \
    $(APPL)/goal_appl_ecat_objects.h \
    $(APPL)/goal_appl.h \
    $(APPL)/goal_appl_http.h \
    $(APPL)/goal_http_fs.h \
    $(APPL)/goal_config.h

export


all:
	@$(MAKE) --no-print-directory -f $(GOAL)/tools/make/Makefile $@


.DEFAULT:
	@$(MAKE) --no-print-directory -f $(GOAL)/tools/make/Makefile $@

gen_http_fs:
	$(GOAL)/tools/generator/goal_gen_http_fs.sh $(GOAL)/$(APPL) $(GOAL)/$(APPL)/html goal_http_fs.h

Line 18:

This path points to the application folder, where source files are located.

Line 22 .. 26:

This section configures features which are part of the project. Available
features are described within the file
$(GOAL)/tools/make/gcc/Makefile.features. In this example the required features for an application controller (AC) are configured which enable:

  • CONFIG_MAKE_FEAT_MCTC_AC: general RPC functionality

  • CONFIG_MAKE_FEAT_LM_EMIT_MA_UART: logging output to a serial console

  • CONFIG_MAKE_FEAT_HTTP: RPC interface for web server

  • CONFIG_MAKE_FEAT_GOAL_ECAT: RPC interface for the EtherCAT stack

  • CONFIG_MAKE_FEAT_DD_CTC_AC: RPC interface for the device detection (DD)

Line 28 .. 45:

This section describes the required source files and used header files. The
list of header files is required for project generation. Only the listed files
will be visible within the target IDE.

Line 50 .. 55:

Required targets, please leave unchanged.

Line 57 .. 58:

This target can be used to generate header files required for the web server.

Installation

On order to use the generators a shell environment is required. Following for
different operating systems a installation procedure is provided.

Linux

Reference system is a Ubuntu Server 20.04.1 64 bit system

  • Install build essentials

    sudo apt-get install build-essential
  • Install perl dependency

    sudo cpan File::Copy::Recursive
    sudo cpan List::MoreUtils

Microsoft Windows

Reference system is Windows 10, version 2004 (10.0.19041.0)

Optionally the Windows subsystem for Linux can be used, then the Linux
installation procedure applies.

    pacman -Syuu
  • Install required tools

    pacman -S git mc zip perl make gcc
  • Install perl dependency

    pacman -S libcrypt-devel perl-File-Copy-Recursive perl-Exporter-Tiny perl-devel
    cd ~
    git clone https://github.com/msys2/MSYS2-packages.git
    cd ~/MSYS2-packages/perl-List-MoreUtils-XS
    makepkg
    pacman -U perl-List-MoreUtils-XS*.pkg.tar.xz
    cd ~/MSYS2-packages/perl-List-MoreUtils
    makepkg
    pacman -U perl-List-MoreUtils*.pkg.tar.xz

MacOS X

Reference system is a OSX Catalina (10.15.6)

    brew install coreutils
    brew install gnu-sed
  • Install perl module

    sudo /usr/bin/cpan File::Copy::Recursive
    sudo /usr/bin/cpan List::MoreUtils

Project generator

The project generator needs to be run within the project folder (where the
Makefile is located).

  • Enter the project folder

cd projects/2015013_irj45/ac/09_ecat_slave/gcc
  • Select a target:

> make select

No platform selected, choose a platform - OR - press <CTRL+c> and set the
PLATFORM environment variable.

Choose platform:
  [ 1] stm32f429_nucleo                (gcc,gdb,ocd)

    Choice [1-1]:

Please select the prefered target from the list of available targets.

  • Run project generator (eclipse)

> make gen_eclipse

Please select the project template from the list of available targets.

Platform selected by .platform file: stm32f429_nucleo


Please select a template - OR - press <CTRL+c> and set the
GEN_ECLIPSE_TPL environment variable.

Choose template:
  [ 1] atollic_nucleo_f429zi
  [ 2] e2studio_s7g2sk
  [ 3] e2studio_synergy
  [ 4] e2studio_synergy_lib
  [ 5] eclipse_mcu
  [ 6] generic
  [ 7] stmcubeide_nucleo_f429zi


Choice [1-7]:

Following table gives a short description of the available targets:

Template

Description

atollic_nucleo_f429zi

Atollic studio project

e2studio_s7g2sk

E2Studio project for s7g2sk

e2studio_synergy

E2Studio project for Aris

e2studio_synergy_lib

E2Studio project for Aris

eclipse_mcu

Generic embedded eclipse project

generic

Generic eclipse project

stmcubeide_nucleo_f429zi

STM32CubeIde project for stm32f4

Table: Available project templates

The project generator will output some details regarding the process:

gen_eclipse
-----------
Project: 2015013_irj45__ac__09_ecat_slave_renesas__stm32f429_nucleo
Templates: tools/make/gen_eclipse/tpls/stmcubeide_nucleo_f429zi
Generating: .project
Output dir: projects/2015013_irj45/ac/09_ecat_slave_renesas/stmcubeide/stm32f429_nucleo

The output folder contains the generated project, which can be imported as an preexisting project into the IDE, e.g. STM32CubeIDE.

HTTP Content generator

The provided tool takes a folder containing files prepared for delivery by the
web server and converts those to a format which can be compiled into the
application binary.

Within the project makefile a target can be created which performs this action:

gen_http_fs:
	$(GOAL)/tools/generator/goal_gen_http_fs.sh $(GOAL)/$(APPL) $(GOAL)/$(APPL)/html goal_http_fs.h

This target calls the bash script goal_gen_http_fs.sh which takes the following
arguments:

  1. target path: where the generated header file goal_http_fs.h is created

  2. source path: folder which contains html files, images, js files ... for web server delivery

  3. target filename

Upon invoking of the generator the target file is created. This file can be
included from the application. For each file within the source file the
following artefacts are created (e.g. from index.html):

binary representation of the file content:

static const unsigned char index_html[] = {
}

length of the file content:

static const unsigned int index_html_len = 1442;

These variables can be used to provide the data to the web server:

/****************************************************************************/
/* Local Variables */
/****************************************************************************/

static GOAL_HTTP_HDL_T hdlIdxHtml;              /**< handle of index html page */


/****************************************************************************/
/** Application Init
 *
 * This function must initialize GOAL and all used protocol stacks.
 * Furthermore application specific resources must be initialized.
 */
GOAL_STATUS_T appl_init(
    void
)
{
    GOAL_STATUS_T res;                          /* result */

    /* initialize HTTP */
    res = goal_httpInit();
    if (GOAL_RES_ERR(res)) {
        goal_logErr("Initialization of HTTP failed");
    }

     return res;
}


/****************************************************************************/
/** Application Setup
 *
 * Setup the application.
 */
GOAL_STATUS_T appl_setup(
    void
)
{
    GOAL_STATUS_T res = GOAL_OK;                /* result */
    GOAL_HTTP_T *pHttpHdl = NULL;               /* http handle */

    goal_logInfo("setup web server");

    /* setup new http instance */
    res = goal_httpNew(&pHttpHdl, 80, 4);
    if (GOAL_RES_ERR(res)) {
        goal_logErr("failed to setup HTTP instance");
    }

    if (GOAL_RES_OK(res)) {
        res = goal_httpResReg(pHttpHdl, (uint8_t *) "/index.html",
                              GOAL_HTTP_METHOD_ALLW_GET,
                              httpDataCb, NULL, &hdlIdxHtml);
    }

    return res;
}


/****************************************************************************/
/** goal http data callback
 *
 */
static GOAL_STATUS_T httpDataCb(
    GOAL_HTTP_APPLCB_DATA_T *pCbInfo            /**< pointer to callback info struct */
)
{
    if (hdlIdxHtml == pCbInfo->hdlRes) {
        /* return index page */
        GOAL_HTTP_GET_RETURN_HTML(pCbInfo, index_html, index_html_len);
    }

    return GOAL_OK;
}
  • No labels