# Recommended way to start new project in Standard SDK

**URL:** <https://forum.amebaiot.com/t/recommended-way-to-start-new-project-in-standard-sdk/1197>\
**Category:** SDK\
**Tags:** evb-amb82\
**Created:** [April 16, 2022, 5:16pm UTC](https://forum.amebaiot.com/t/recommended-way-to-start-new-project-in-standard-sdk/1197 "2022-04-16T17:16:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![boatbodger](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@boatbodger](https://forum.amebaiot.com/u/boatbodger)\
**Post date:** [April 16, 2022, 5:16pm UTC](https://forum.amebaiot.com/t/recommended-way-to-start-new-project-in-standard-sdk/1197/1 "2022-04-16T17:16:18Z")

</div>

I have managed to get the examples in the standard SDK to compile and function.  
What is the cleanest way to start building my own project (making use of snippets from the examples, of course)?  
It seems a bit untidy to just start modifying files in the Examples source trees. Initially I thought I would simply ‘clone’ the folder ambd\_sdk/project/realtek\_amebaD\_va0\_example - but it is massive - 4GB.  
Furthermore, it seems somehow to be linked to ambd\_sdk/component/common/example  
I did start trying to understand the various Makefiles involved, but very quickly got lost ☹

I feel I need a way to ‘point’ the build process at my own instances of src\_hp and src\_lp, and ideally just modify the main.c files, replacing example\_entry() with my\_project\_entry() with my various project modules in a subdirectory - perhaps under ambd\_sdk/project thereby avoiding “polluting” the SDK tree, meaning that if the SDK gets updated, I can relatively easy port my project to the newer version.

Perhaps there’s another AN which I’ve missed? I have looked in AN400 a few times, and can’t find any documents in ambd\_sdk/doc which help me on this point.

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [April 17, 2022, 11:22am UTC](https://forum.amebaiot.com/t/recommended-way-to-start-new-project-in-standard-sdk/1197/2 "2022-04-17T11:22:14Z")

</div>

> [@boatbodger](#):
>
> Initially I thought I would simply ‘clone’ the folder ambd\_sdk/project/realtek\_amebaD\_va0\_example - but it is massive - 4GB.

most of the space there is taken by the toolchain found in `GCC_RELEASE`, the space taken by actual code in `example_sources`, `inc`, `src` is about 50 MB.

example code are generally round in three folders:

- `\project\realtek_amebaD_va0_example\example_sources` for peripherals
- `\component\common\example` for various applications
- `\component\common\bluetooth\realtek\sdk\example` for BLE

example\_entry() is more of a default code that calls the various example code that are activated. Depending on what you want to do, it may be easier to start with an empty main.c and copy in code for the functionalities you need.

---

<div class="post-metadata">

**Author:** ![boatbodger](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@boatbodger](https://forum.amebaiot.com/u/boatbodger)\
**Post date:** [April 17, 2022, 4:28pm UTC](https://forum.amebaiot.com/t/recommended-way-to-start-new-project-in-standard-sdk/1197/3 "2022-04-17T16:28:34Z")

</div>

Is it the case that any .c files which I add in to `\component\common\example` will automatically get compiled, so that if I created a file called my\_application.c there, with a function in it called my\_entry(), and the replace the call to example\_entry() in main.c with my\_entry() (assuming I also create an appropriate .h file to provide the prototype to main.c)

Or is there some part of the make configuration where the various c files have to be listed in order that they should be compiled?

On reflection, perhaps a better way to start my question would be ‘how does the make system know that example\_entry.c needs to be built?’ for the standard examples

Forgive my ignorance, here!

---

<div class="post-metadata">

**Author:** ![wyy](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wyy](https://forum.amebaiot.com/u/wyy)\
**Post date:** [April 18, 2022, 2:44am UTC](https://forum.amebaiot.com/t/recommended-way-to-start-new-project-in-standard-sdk/1197/4 "2022-04-18T02:44:13Z")

</div>

> [@boatbodger](#):
>
> Or is there some part of the make configuration where the various c files have to be listed in order that they should be compiled?
> 
> On reflection, perhaps a better way to start my question would be ‘how does the make system know that example\_entry.c needs to be built?’ for the standard examples

Basically, every file that needs to be compiled is listed in a makefile somewhere. For the example code in `\component\common\example`, the corresponding makefile is found in `\project\realtek_amebaD_va0_example\GCC-RELEASE\project_hp\asdk\make\utilities_example`

AN0400 Chapter 3 has an overview of the makefile hierarchy tree, and also recommends that user additions to the makefile should go into `\project\realtek_amebaD_va0_example\GCC-RELEASE\project_hp\asdk\make\project`, where you can choose to run your code from flash or sram.

---

<div class="post-metadata">

**Author:** ![boatbodger](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@boatbodger](https://forum.amebaiot.com/u/boatbodger)\
**Post date:** [April 18, 2022, 10:42am UTC](https://forum.amebaiot.com/t/recommended-way-to-start-new-project-in-standard-sdk/1197/5 "2022-04-18T10:42:14Z")

</div>

Ah - OK - I think I’m getting there - the significance of AN400 chapter 3 is now much clearer to me - thank you.  
So What I have done so far is:

- copy project\_hp\asdk\make\project\xip to project\_hp\asdk\make\project\myproj
- In myproj, I have renamed xip\_test.c to myproj.c and edited it to have my main entry (which will in due course spawn the various tasks), removing the reference to RAM-based code
- in myproj, I have also edited the Makefile so that CUSTOMER\_DIR points to …\project\myproj, and changed the OBJS line to generate myproj.o rather than xip\_test.o
- In …\project, I have edited **that** Makefile to add lines in to the all: and clean: sections as ‘make -C myproj all’ and ‘make myproj clean’
- finally, I went to back to ambd\_sdk/project/realtek\_amebaD\_va0\_example/src, made a safety copy of main.c and edited main.c to contain a prototype for my entry function (myproj\_entry() in myproj.c), and then replaced example\_entry() with myproj\_entry()

I can now do a ‘make all’ from the project\_up directory and can see that myproj.c has been compiled, and that myproj\_entry() is successfully linked in.

Now to start adding my functionality borrowing from the examples wherever possible.

Thank you too, for pointing out the option to run critical code in SRAM - my application does have a few functions which are time critical so I will experiment with that to see whether it makes a useful performance improvement.

---

<div class="post-metadata">

**Author:** ![boatbodger](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@boatbodger](https://forum.amebaiot.com/u/boatbodger)\
**Post date:** [April 21, 2022, 10:35am UTC](https://forum.amebaiot.com/t/recommended-way-to-start-new-project-in-standard-sdk/1197/6 "2022-04-21T10:35:29Z")

</div>

Further to the above, I wanted to make use of the platform\_opts.h option CONFIG\_INTERACTIVE\_EXT so that I could use this facility for extending the command interpreter.  
When this flag is switched on, ‘component\common\api\wifi\_interactive\_mode.c’ seeks to include a header ‘wifi\_interactive\_mode\_ext.h’  
I was not sure where to put this, but found that placing it in ‘/home/chris/ambd\_sdk/project/realtek\_amebaD\_va0\_example/inc/inc\_hp’ worked nicely, so I have made a soft link there to the actual source file which is under the project/myproj folder described in my previous post.

I am hoping the steps above have minimised the disruption to the as-published SDK - happy to take on board any comments.

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [April 22, 2022, 3:14am UTC](https://forum.amebaiot.com/t/recommended-way-to-start-new-project-in-standard-sdk/1197/7 "2022-04-22T03:14:49Z")

</div>

cool~ 👍👍👍 😀
