Getting started with standard SDK

Hi, I’m moving from the Arduino SDK to the standard SDK and I’m quite lost.

I’ve setup the enviroment in a linux box and, if I go tto ~/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp and issue a make all command, it works and I end up with the proper files in asdk/images. But, I don’t kown what I’ve built!!!

What will be the next step to create a very simple project that just connect to a WiFi Network??

My code will look something like this:

#include “FreeRTOS.h”
#include “task.h”
#include “diag.h”
#include “main.h”
#include “wifi_conf.h”
void main(void)
{

wifi_on(RTW_MODE_STA);
wifi_connect(“MyNet”,RTW_SECURITY_WPA_TKIP_PSK,“mypass”,5,6);
vTaskStartScheduler();
}

Any help will be very much appreciated!!

Dear @Chano,

  1. make all in project_hp(low power core) is usually followed by make all in project_lp(low power core) first due to some of the lib dependencies.
  2. your target code should be placed under ambd_sdk\project\realtek_amebaD_va0_example\src\src_hp\main.c before compilation.
  3. output image will be stored in ambd_sdk\project\realtek_amebaD_va0_example\GCC-RELEASE\project_hp\asdk\image folder. You will find 3 .bin files uploading to flash, 2 for bootloaders, and 1 is the actual image. Please download AN0400 to know more details about the standard sdk compilation process.

Thank you.

Hi again, after a very long reading and testing I finally was able to compile my first program. It’s just a very simple program to scan networks and connect to one. This is the code:

#include “ameba_soc.h”
#include <wifi_conf.h>

int main( void)
{
int rc;
rtw_scan_result_t **salida;

  DiagPrintf("Hello World"); 
  wifi_on(RTW_MODE_STA); 
  DiagPrintf("Scanning Network");

  rc=wifi_scan(RTW_SCAN_TYPE_ACTIVE,RTW_BSS_TYPE_ANY,salida);
  if (rc == RTW_SUCCESS)
  {
  			DiagPrintf("Scan Complete");
  }
  else	
  			DiagPrintf("Scan Error %d",rc);		


  rc=wifi_connect("Chano2",RTW_SECURITY_WPA_TKIP_PSK,"2de01ad4",6,8,-1,NULL); 
  if (rc == RTW_SUCCESS)
  			DiagPrintf("Connected to Wifi ");
  else	
  			DiagPrintf("Not connected %d",rc);

}

I’ve placed the main.c in ambd_sdk\project\realtek_amebaD_va0_example\src\src_hp\main.c and run make all in ~/ambd_sdk/project/realtek_amebaD_va0_example/GCC-RELEASE/project_hp

I’ve used imagetool to download the code to my BW16 dev board. I have place at addr 0x08000000 km0_boot_all.bin (this file cames from ambd_sdk\project\realtek_amebaD_va0_example\GCC-RELEASE\ project_lp \asdk\image\km0_boot_all.bin because there is not such file in project_hp/images folder.

at addr 0x08004000 km4_boot_all.bin and at 0x08006000 km0_km4_image2.bin.
Download it without problems.

When I connect to my board this is the output that I get:

#calibration_ok:[2:19:11]
Hello World
Initializing WIFI …

Seems like board hangs at “wiif_on” …

Any clue??
Thx on advance.

This is a tough road… :cold_sweat:

I’ve seen this post https://forum.amebaiot.com/t/rtl8720dn-cannot-initialize-wifi-in-standard-sdk/900 and seems like I have to start an RTOS task first (makes sense).

I wont be able to test it in a couple days due to a business trip, but I’ll post any progress here.

Thx!

Fortunately, the mentioned post was correct. This code works! It ended like this and works:

#include “ameba_soc.h”
#include <wifi_conf.h>

int init( void)
{
int rc;
rtw_scan_result_t **salida;

  DiagPrintf("Task started"); 
  wifi_on(RTW_MODE_STA); 
  DiagPrintf("Scanning Network");

  rc=wifi_scan(RTW_SCAN_TYPE_ACTIVE,RTW_BSS_TYPE_ANY,salida);
  if (rc == RTW_SUCCESS)
  {
  			DiagPrintf("Scan Complete");
  }
  else	
  			DiagPrintf("Scan Error %d",rc);		


  rc=wifi_connect("Chano2",RTW_SECURITY_WPA_TKIP_PSK,"2de01ad4",6,8,-1,NULL); 
  if (rc == RTW_SUCCESS)
  			DiagPrintf("Connected to Wifi ");
  else	
  			DiagPrintf("Not connected %d",rc);

}

int main(void)
{
DiagPrintf(“Main started”);
xTaskCreate(init, ((const char*)“init”), 512 + 768, NULL, tskIDLE_PRIORITY + 3 + PRIORITIE_OFFSET, NULL);
vTaskStartScheduler();
}
Seems like I’m on the road!!

Next Step, Mqtt connection…

1 Like

Well, once again I’m stuck. There is something I’m not understanding of this SDK…

I’ve prepared my code for MQTT based in the example, but the first thing that fails is:

#include “MQTTClient.h”
I get

main.c:4:24: fatal error: MQTTClient.h: No such file or directory

I’ve already do a make menuconfig and enabled MQTT but seems like this is not enough

Any help will be appreciate, an any reading regarding on how this SDK works will be welcome (AN00400 is not very clear…)

Thx

@Chano
You can refer to this doc.
ambd_sdk/component/common/example/mqtt at dev · ambiot/ambd_sdk (github.com)