Recommended way to start new project in Standard SDK

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 :frowning:

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.

1 Like

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.

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!

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.

1 Like

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.

1 Like

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.


cool~ :+1::+1::+1: :grinning: