cancel
Showing results for 
Search instead for 
Did you mean: 

How to import example from GitHub?

MHoop.1
Senior

I am trying to import an example project into my CubeIDE workspace that I have downloaded from GitHub and need some clarification on the process.

I have downloaded (for example) x-cube-azrtos-h7-main from GitHub. I have unzipped the main file into my local repository folder. I then select File->Import->Existing Projects into Workspace which brings up the Import Projects window. I then select the "\Projects\NUCLEO-H723ZG\Applications\NetXDuo\Nx_TCP_Echo_Server" project and the click on "Finish". After the project is imported, there are yellow exclamation indicators on all of the .c files listed in the project file structure. The clicking on any of the files shows that there is no actual file in the folder.

0693W00000Y8CECQA3.png 

I have also tried File->Import->Projects from Folder or Archive (which I am not sure how this is different). This doesn't actually copy files into my workspace. It only creates a link to the original file location in my repository, which I don't want.

How do I import a copy of an existing project from my repository into my workspace?

Thx,

MikeH

14 REPLIES 14
Karl Yamashita
Lead II

It could be the GitHub project has missing files. I've downloaded directly from ST and the the project you are importing compiles for me with no errors

https://www.st.com/en/embedded-software/x-cube-azrtos-h7.html

Pavel A.
Evangelist III

Strange, the path of main.c looks ok.

https://github.com/STMicroelectronics/x-cube-azrtos-h7/blob/57faa03d093cb37ad341798d76886af15decdc74/Projects/NUCLEO-H723ZG/Applications/NetXDuo/Nx_TCP_Echo_Server/STM32CubeIDE/.project#L162

Have you used git to clone the repo or downloaded it as zip?

The project is already made for CubeIDE. Use Import ... Existing project into workspace - without any conversion.

MHoop.1
Senior

Still struggling with this. Let me clarify.

I am attempting to "import" an existing example project from my repo (means COPY code into my workspace, not link to external code in my repo). The repo files were downloaded from GitHub (x-cube-azrtos-h7-main). The workspace I want the imported projects to be copied into is workspace H7, which is the currently active workspace of CubeIDE.

There seem to be two ways to do this. Not sure now these are different.

  1. Import->Existing Projects Into Workspace.
  2. Import->Projects from Folder or Archive.

When using technique #1 I get two "projects" in the import window:

0693W00000aIamQQAS.pngIf I select BOTH projects, I get the following error message.

0693W00000aIam7QAC.pngHOWEVER, the projects have been imported and all example files do exist in the workspace H7.

BUT, the build hammer is greyed out and i cannot build the project.

0693W00000aIayMQAS.png 

So if I erase the ..metadata file and all contents on the workspace H7 folder, then attempt to import ONLY the STM32CubeIDE project, I get the following. The yellow exclamation point apparently means the "file does not exist".

0693W00000aIasYQAS.pngThis is confirmed by looking at the "resource" in the project properties window (resolved location).

0693W00000aIavDQAS.pngUpon examining the workspace H7 using windows file explorer, I find that none of the files have been copied over. So apparently I DO need both projects, but am not able to import them because CubeIDE still thinks they exist in the workspace H7???? And the build hammer is greyed out??

So if I attempt to use import method #2 above, I get the following:

0693W00000aIazAQAS.pngAgain it show two projects to import. But it does not show a way to "copy" the files into workspace H7.

After importing using methods #2, i get the following project file structure.

0693W00000aIb0wQAC.pngOnce again, build hammer is greyed out so that I cannot build the project.

WTF?

I'm sure there is some very simple explanation for what is going on.

Can someone please notify the CubeIDE ghuru (can't remember his name, but he was aquired by STM for his Atollic TruStudio product). I'm sure he has a quick-easy solution for me.

Thx,

Mikeh

MHoop.1
Senior

So, here is part of the problem I am seeing. I guess this renders "hierarchical" example projects useless until this is fixed.

0693W00000aIhoTQAS.png

Pavel A.
Evangelist III

> I am attempting to "import" an existing example project from my repo (means COPY code into my workspace, not link to external code in my repo).

Eclipse unfortunately is less intuitive/more confusing than it could be.

"Import project into workspace" does not always mean "copy the code into my workspace".

It means preparing the project so that Eclipse sees it (in context of a workspace).

Copying stuff into the workspace is optional. Conversion is optional.

In this specific case you don't want either.

Try to only import the project as is, since it is already a CubeIDE project.

Let's do it again, slowly, step by step, with latest CubeIDE v.1.12 and STM32H7 libraries already installed.

1. Take a clean saucepan. Create a new directory for the workspace or carefully delete remnants of the project from existing workspace.

2 File->Import->General-> Existing project into workspace

(not "from folder or archive" etc.)

3 Browse to .... Repository\Packs\STMicroelectronics\X-CUBE-AZRTOS-H7\3.0.0\Projects\NUCLEO-H723ZG\Applications\NetXDuo\Nx_TCP_Echo_Server

or copy & paste the path.

Note: the cube repo path (and therefore the project path) must be spaces-free. Else, move the cube repo to spaces-free path.

Then Eclipse should see one and only one project in the STM32CubeIDE subdir.

Do NOT check "copy projects into workspace".

4 Click Finish.

The project imports without a hitch.

5 Click Refresh, Build (the hammer icon)

The project builds without a hitch.

Pavel A.
Evangelist III

(continued)

CubeIDE has another tool, File->Import->General->Import STM32Cube example.

This (after a lot of "target selector" powerlifting) converts the project to CubeIDE format if it is for something else, and copies most of the stuff into your workspace.

So, start it, type "Nx_TCP_Echo_Server" into the box and select your board NUCLEO-H723ZG.

After another 10 minutes or so of copying, the project is ready and compiles well.

In your case the project was already for CubeIDE so no conversion.

There are other project import options, some working, some not, some not intended for STM32 projects. Explore in your spare time.

Pavel A.
Evangelist III

(continued)

Finally to answer your question: How to import example from GitHub?

AFAIK this is straightforward only for examples where all components are in the "jumbo" MCU package available on github,

Your example cannot be installed just by clone or download from github, because it uses additional pack X-CUBE-AZRTOS-H7.

It needs the CubeIDE "pack installer" magic to get these X packs into the correct places.

Pavel,

First of all, THANK YOU for taking time to address this. Apparently STM folks don't care.

"1. Take a clean saucepan. Create a new directory for the workspace or carefully delete remnants of the project from existing workspace."

Done.

"2 File->Import->General-> Existing project into workspace

(not "from folder or archive" etc.)"

Done.

"3 Browse to .... Repository\Packs\STMicroelectronics\X-CUBE-AZRTOS-H7\3.0.0\Projects\NUCLEO-H723ZG\Applications\NetXDuo\Nx_TCP_Echo_Server"

Done.

"Note: the cube repo path (and therefore the project path) must be spaces-free. Else, move the cube repo to spaces-free path."

Done.

"Then Eclipse should see one and only one project in the STM32CubeIDE subdir."

NO! There are always two projects shown in this window. So apparently, this example is a "hierarchical" project. Below is what I see.

0693W00000aIipmQAC.pngIf I then click on "Finish" I get the following error message.

0693W00000aIiprQAC.pngThis happens every time, even with a clean (i.e. no files) in the newly created workspace.

"CubeIDE has another tool, File->Import->General->Import STM32Cube example."

I have tried this repeatedly, with two different Nucleo boards. But the STM32CubeIDE examples (at least the NX_TCP_Echo_Server example) are INCOMPLETE and are only a framework for the example. It compiles and runs, but does not contain the actual server code. That's why I am attempting to use the Git examples.

Take a look at the app_netxduo.c code. It does compile and initializes 3 threads, BUT THAT'S ALL IT DOES. The actual packet reception and processing does not exist in the "example". This "minor detail" is left to the developer. And, there is no printf displaying the IP address or port. This same problem exists for both the H7 example code, AND the F4 example code.

/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    app_netxduo.c
  * @author  MCD Application Team
  * @brief   NetXDuo applicative file
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2020-2021 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
 
/* USER CODE END Header */
 
/* Includes ------------------------------------------------------------------*/
#include "app_netxduo.h"
 
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
 
/* USER CODE END Includes */
 
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
 
/* USER CODE END PTD */
 
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
 
/* USER CODE END PD */
 
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
 
/* USER CODE END PM */
 
/* Private variables ---------------------------------------------------------*/
TX_THREAD      NxAppThread;
NX_PACKET_POOL NxAppPool;
NX_IP          NetXDuoEthIpInstance;
/* USER CODE BEGIN PV */
 
/* USER CODE END PV */
 
/* Private function prototypes -----------------------------------------------*/
static VOID nx_app_thread_entry (ULONG thread_input);
/* USER CODE BEGIN PFP */
 
/* USER CODE END PFP */
 
/**
  * @brief  Application NetXDuo Initialization.
  * @param memory_ptr: memory pointer
  * @retval int
  */
UINT MX_NetXDuo_Init(VOID *memory_ptr)
{
  UINT ret = NX_SUCCESS;
  TX_BYTE_POOL *byte_pool = (TX_BYTE_POOL*)memory_ptr;
  CHAR *pointer;
 
  /* USER CODE BEGIN MX_NetXDuo_MEM_POOL */
  (void)byte_pool;
  /* USER CODE END MX_NetXDuo_MEM_POOL */
 
  /* USER CODE BEGIN 0 */
 
  /* USER CODE END 0 */
 
  /* Initialize the NetXDuo system. */
  nx_system_initialize();
 
    /* Allocate the memory for packet_pool.  */
  if (tx_byte_allocate(byte_pool, (VOID **) &pointer, NX_APP_PACKET_POOL_SIZE, TX_NO_WAIT) != TX_SUCCESS)
  {
    return TX_POOL_ERROR;
  }
 
  /* Create the Packet pool to be used for packet allocation,
   * If extra NX_PACKET are to be used the NX_APP_PACKET_POOL_SIZE should be increased
   */
  ret = nx_packet_pool_create(&NxAppPool, "NetXDuo App Pool", DEFAULT_PAYLOAD_SIZE, pointer, NX_APP_PACKET_POOL_SIZE);
 
  if (ret != NX_SUCCESS)
  {
    return NX_POOL_ERROR;
  }
 
    /* Allocate the memory for Ip_Instance */
  if (tx_byte_allocate(byte_pool, (VOID **) &pointer, Nx_IP_INSTANCE_THREAD_SIZE, TX_NO_WAIT) != TX_SUCCESS)
  {
    return TX_POOL_ERROR;
  }
 
   /* Create the main NX_IP instance */
  ret = nx_ip_create(&NetXDuoEthIpInstance, "NetX Ip instance", NX_APP_DEFAULT_IP_ADDRESS, NX_APP_DEFAULT_NET_MASK, &NxAppPool, nx_stm32_eth_driver,
                     pointer, Nx_IP_INSTANCE_THREAD_SIZE, NX_APP_INSTANCE_PRIORITY);
 
  if (ret != NX_SUCCESS)
  {
    return NX_NOT_SUCCESSFUL;
  }
 
    /* Allocate the memory for ARP */
  if (tx_byte_allocate(byte_pool, (VOID **) &pointer, DEFAULT_ARP_CACHE_SIZE, TX_NO_WAIT) != TX_SUCCESS)
  {
    return TX_POOL_ERROR;
  }
 
  /* Enable the ARP protocol and provide the ARP cache size for the IP instance */
 
  /* USER CODE BEGIN ARP_Protocol_Initialization */
 
  /* USER CODE END ARP_Protocol_Initialization */
 
  ret = nx_arp_enable(&NetXDuoEthIpInstance, (VOID *)pointer, DEFAULT_ARP_CACHE_SIZE);
 
  if (ret != NX_SUCCESS)
  {
    return NX_NOT_SUCCESSFUL;
  }
 
  /* Enable the ICMP */
 
  /* USER CODE BEGIN ICMP_Protocol_Initialization */
 
  /* USER CODE END ICMP_Protocol_Initialization */
 
  ret = nx_icmp_enable(&NetXDuoEthIpInstance);
 
  if (ret != NX_SUCCESS)
  {
    return NX_NOT_SUCCESSFUL;
  }
 
  /* Enable TCP Protocol */
 
  /* USER CODE BEGIN TCP_Protocol_Initialization */
 
  /* USER CODE END TCP_Protocol_Initialization */
 
  ret = nx_tcp_enable(&NetXDuoEthIpInstance);
 
  if (ret != NX_SUCCESS)
  {
    return NX_NOT_SUCCESSFUL;
  }
 
  /* Enable the UDP protocol required for  DHCP communication */
 
  /* USER CODE BEGIN UDP_Protocol_Initialization */
 
  /* USER CODE END UDP_Protocol_Initialization */
 
  ret = nx_udp_enable(&NetXDuoEthIpInstance);
 
  if (ret != NX_SUCCESS)
  {
    return NX_NOT_SUCCESSFUL;
  }
 
   /* Allocate the memory for main thread   */
  if (tx_byte_allocate(byte_pool, (VOID **) &pointer, NX_APP_THREAD_STACK_SIZE, TX_NO_WAIT) != TX_SUCCESS)
  {
    return TX_POOL_ERROR;
  }
 
  /* Create the main thread */
  ret = tx_thread_create(&NxAppThread, "NetXDuo App thread", nx_app_thread_entry , 0, pointer, NX_APP_THREAD_STACK_SIZE,
                         NX_APP_THREAD_PRIORITY, NX_APP_THREAD_PRIORITY, TX_NO_TIME_SLICE, TX_AUTO_START);
 
  if (ret != TX_SUCCESS)
  {
    return TX_THREAD_ERROR;
  }
 
  /* USER CODE BEGIN MX_NetXDuo_Init */
 
  /* USER CODE END MX_NetXDuo_Init */
 
  return ret;
}
 
/**
* @brief  Main thread entry.
* @param thread_input: ULONG user argument used by the thread entry
* @retval none
*/
static VOID nx_app_thread_entry (ULONG thread_input)
{
  /* USER CODE BEGIN Nx_App_Thread_Entry 0 */
 
  /* USER CODE END Nx_App_Thread_Entry 0 */
 
}
/* USER CODE BEGIN 1 */
 
/* USER CODE END 1 */

Whereas, if you look at the same file from the Git example (attached), IT CONTAINS A COMPLETE EXAMPLE WHICH RUNS PROPERLY. I have had this running in the past, but for some reason after updating the CubeIDE V1.12 I cannot reproduce my success.

FYI, I have attempted to modify the CubeIDE-generated examples to match the Git example, but I run into many problems. In my opinion, "examples" should be complete working examples so that I can step through working code to see how it is supposed to work, so that I can gain the knowledge required to further modify the code with my requirements. However the path that I am on seems like an endless series of frustrating dead-ends.

Again, thanks for trying to help, but I think STM has a lot of work left to do .....