Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,036 Views

How to create 2nd project referencing same BSP and source files?

I've created my main application and BSP using the "New Nios II Application and BSP from Template" wizard. I used the "Hello MicroC/OS-II" template because my application uses the RTOS. I've added multiple source files to my project. All of this is setup and working fine. 

 

Now I want to create a second project for a boot program in the same workspace. The boot program will be a stripped down version of my main application. The boot program should use the same BSP and a subset of the same source files used by the main application. What is the best way to create this new project in the Nios II EDS? 

 

If I use the "New Nios II Application" wizard I can specify the existing BSP, but there is no option for a MicroC/OS-II template. How do I configure the new project for MicroC/OS-II? Is there an easy way to copy the settings from my main application project? 

 

How should I add the existing source files to the new project so that I don't create a new copy of the source files. I want the same source files to be referenced by the both projects so that I don't need to change the source code in two places. Is the "Link to file in the file system" Advanced option what I want to use for this? When I try this option, the New file wizard displays a warning, "file may overlap another resource. This can cause unexpected side-effects." Is this a real concern or are the "unexpected side-effects" referring to the effect that I'm going for? 

 

Thanks for any advice.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor I
39 Views

I tried the following but it is not working. I used the "New Nios II Application" wizard to create a new project named "boot". I specified the existing BSP in the wizard. Then, within the new project, I used the New File wizard to add each source file individually. For each file I selected the Advanced "Link to file in the file system" option and browsed to the existing source file under my "main" project folder. I also right-clicked on each boot project source file in the Project Explorer pane and selected "Add to Nios II Build" because they were not added by default. But when I build the boot project, the builder does not attempt to compile the linked source files. It goes straight to linking as if they were pre-compiled or something. I don't understand this behavior. 

 

Also, I did not find an easy way to copy the project settings from the main project to the boot project. The boot project was created without the MicroC/OS-II related settings because there is no template option through the "New Nios II Application" wizard. I tried exporting the main project settings and importing them into the boot project but that doesn't work. The import fails silently and the exported XML settings file appears to be devoid of actual settings. So I manually copied each include path and symbol from one project to the other. I'm not sure whether there are other important settings that should be copied.
Altera_Forum
Honored Contributor I
39 Views

One of the problems with my previous attempts to link the source code from the main project into the boot project is that the source code resides in the main project folder along with a Makefile. When building the boot project, the builder seems to use the wrong Makefile or at least be confused by the Makefile that exists in folder with the source code. For example, the reason my previous boot build skipped the compilation step is because object files for the source files already existed under the main project. The boot project was mistakenly referencing the main project's object files. If I cleaned the main project then the boot project would compile the source code because the main project's object files no longer existed. 

 

So I may have found a solution, which is to put all the source code in a folder that is separate from the project folders (where the Makefiles are) 

 

When I use the New Nios II Application and BSP Template, it creates a folder structure like this 

.... software 

........ main 

............ Makefile 

........ main_bsp 

............ Makefile 

.... workspace 

 

Instead of adding my source code files to the main folder, I created a software\source folder to contain the source files. Then open the main Project Properties and under C/C++ General -> Paths and Symbols open the Source Location tab and click "Link Folder". Add the software\source folder and click "OK". Then in the Project Explorer pane, expand the linked source folder, select all the c/cpp files and select "Add to Nios II Build". Now you can build the main project using the source code from a linked folder. 

 

Next you add the boot project and link the same source folder in the same way. 

 

I also learned that you can use the New Application and BSP from Template wizard to add the boot project without also adding another BSP. Click Next within the wizard to go to the second page and click on "Select an existing BSP project from your workspace". I think it's important to use this template in my case because I'm using uc/OS-II and the template seems to add some important settings related to the RTOS. 

 

In the end my folder structure now looks like this: 

.... software 

........ boot 

............ Makefile 

........ main 

............ Makefile 

........ main_bsp 

............ Makefile 

........ source 

............ *.c/cpp 

.... workspace
Reply