Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to generate LoRaWAN AT firmware for missing regions #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion platform/system/printf-stdarg.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <stdbool.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint-gcc.h>
#include <stdint.h>
#include "tremo_uart.h"

#include "tremo_regs.h"
Expand Down
22 changes: 22 additions & 0 deletions projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,36 @@ $(PROJECT)_INC_PATH := inc \
$(TREMO_SDK_PATH)/lora/linkwan/region

$(PROJECT)_CFLAGS := -Wall -Os -ffunction-sections -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -fsingle-precision-constant -std=gnu99 -fno-builtin-printf -fno-builtin-sprintf -fno-builtin-snprintf
$(PROJECT)_ADDRESS := 0x08008000

#自己添加的根据 LoraWanRegionDefine 编译不同频段的LoRaWAN
ifeq ($(LoraWanRegionDefine),REGION_EU868)
$(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionEU868.c
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_EU868 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA
else ifeq ($(LoraWanRegionDefine),REGION_EU433)
$(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionEU433.c
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_EU433 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA
else ifeq ($(LoraWanRegionDefine),REGION_AU915)
$(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionAU915.c
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_AU915 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA
else ifeq ($(LoraWanRegionDefine),REGION_US915)
$(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionUS915.c
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_US915 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA
else ifeq ($(LoraWanRegionDefine),REGION_AS923)
$(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionAS923.c
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_AS923 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA
else ifeq ($(LoraWanRegionDefine),REGION_CN779)
$(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionCN779.c
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_CN779 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA
else ifeq ($(LoraWanRegionDefine),REGION_IN865)
$(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionIN865.c
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_IN865 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA
else ifeq ($(LoraWanRegionDefine),REGION_KR920)
$(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionKR920.c
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_KR920 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA
else ifeq ($(LoraWanRegionDefine),REGION_US915-Hybrid)
$(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionUS915-Hybrid.c
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_US915-Hybrid -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA
else
$(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionCN470.c
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_CN470 -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,52 @@
#ifndef __AITHINKER_CODE_H__
#define __AITHINKER_CODE_H__
#include<stdint.h>
#ifndef __AITHINKER_CODE_H__
#define __AITHINKER_CODE_H__
#include<stdint.h>

//下面是Aithinker工程添加
//#define FARMWARE_VERSION "debug/v1.3.4" //软件版本(这个是替代了 CONFIG_VERSION 的作用)
#define FARMWARE_VERSION "release/v1.3.4" //软件版本(这个是替代了 CONFIG_VERSION 的作用)
//#define FARMWARE_VERSION "debug/v1.3.4" //软件版本(这个是替代了 CONFIG_VERSION 的作用)
#define FARMWARE_VERSION "release/v1.3.4" //软件版本(这个是替代了 CONFIG_VERSION 的作用)
//LoRaWAN国家设置
#ifdef REGION_EU868
#define LORAWAN_REGION_STR "EU868"
#elif defined(REGION_EU433)
#define LORAWAN_REGION_STR "EU433"
#elif defined(REGION_AU915)
#define LORAWAN_REGION_STR "AU915"
#elif defined(REGION_US915)
#define LORAWAN_REGION_STR "US915"
#elif defined(REGION_AS923)
#define LORAWAN_REGION_STR "AS923"
#elif defined(REGION_CN779)
#define LORAWAN_REGION_STR "CN779"
#elif defined(REGION_IN865)
#define LORAWAN_REGION_STR "IN865"
#elif defined(REGION_KR920)
#define LORAWAN_REGION_STR "KR920"
#elif defined(REGION_US915-Hybrid)
#define LORAWAN_REGION_STR "US915H"
#else
#define LORAWAN_REGION_STR "CN470"
#endif

//事件状态机,每个位表示一个事件
#define EVENT_AITHINKER (1<<0) //开发板测试事件
#define EVENT_LEDTEST (1<<1) //LED测试事件
//aithinker 指令
#define LORA_AT_SYSGPIOWRITE "+SYSGPIOWRITE"
#define LORA_AT_SYSGPIOREAD "+SYSGPIOREAD"
#define LORA_AT_NODEMCUTEST "+NodeMCUTEST"
#define LORA_AT_LEDTEST "+LEDTEST"
#define EVENT_LEDTEST (1<<1) //LED测试事件

//aithinker 指令
#define LORA_AT_SYSGPIOWRITE "+SYSGPIOWRITE"
#define LORA_AT_SYSGPIOREAD "+SYSGPIOREAD"
#define LORA_AT_NODEMCUTEST "+NodeMCUTEST"
#define LORA_AT_LEDTEST "+LEDTEST"

extern volatile uint32_t g_aithinkerEvent;
extern uint8_t g_ledIndex;
extern uint8_t *g_pAtCmd;
void AithinkerPrintInfo(void);
void AithinkerEventProcess(void);
int at_sysGpioWrite_func(int opt, int argc, char *argv[]);
int at_sysGpioRead_func(int opt, int argc, char *argv[]);
int at_nodeMcuTest_func(int opt, int argc, char *argv[]);
int at_ledTest_func(int opt, int argc, char *argv[]);
#endif //end of __AITHINKER_CODE_H__
extern uint8_t g_ledIndex;
extern uint8_t *g_pAtCmd;

void AithinkerPrintInfo(void);
void AithinkerEventProcess(void);
int at_sysGpioWrite_func(int opt, int argc, char *argv[]);
int at_sysGpioRead_func(int opt, int argc, char *argv[]);
int at_nodeMcuTest_func(int opt, int argc, char *argv[]);
int at_ledTest_func(int opt, int argc, char *argv[]);

#endif //end of __AITHINKER_CODE_H__
41 changes: 41 additions & 0 deletions projects/ASR6601CB-EVAL/examples/lorawan/lorawan_at/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Extra LoraWAN AT building information
The AT firmware as presented in this SDK requires the OTA firmware installed, which has to be either installed by flashing full original LORAWAN AT firmware first, or by building it in [../../ota/bootloader/](../../ota/bootloader/) directory and flashing it before installing the custom-built AT firmware.

To build AT firmware for your specific LoRaWAN band, follow the instructions in main document [/readme.md](/readme.md), especially

```
source build/envsetup.sh
```

Before building the specific variant of the firmware, use one of following lines to export the correct variable (not needed for CN470 band):

```
export LoraWanRegionDefine=REGION_EU868 # for Ra-08H EU
export LoraWanRegionDefine=REGION_US915 # for Ra-08H US band
export LoraWanRegionDefine=REGION_AU915 # for Ra-08H Australia band
export LoraWanRegionDefine=REGION_EU433 # for Ra08 EU 433 band
export LoraWanRegionDefine=REGION_CN470 # for Ra08 CN 470 band (default if this variable is not set)
...
```
After that, you can continue with

```
make clean
make
make flash # do not forget to put the board in download mode first
```

You can add any future aditional regions by modifying the *Makefile* and *inc/aithinker_code.h* to support them. The additional available bands can be found in [/lora/mac/region](/lora/mac/region/) directory. The modifications would look like this:

```
else ifeq ($(LoraWanRegionDefine),REGION_XXFFF)
$(PROJECT)_SOURCE += $(TREMO_SDK_PATH)/lora/mac/region/RegionXXFFF.c
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DREGION_XXFFF -DCONFIG_LWAN -DCONFIG_LWAN_AT -DCONFIG_LOG -DPRINT_BY_DMA

```
in Makefile before final else, and in *inc/aithinker_code.h*
```
#elif defined(REGION_XXFFF)
#define LORAWAN_REGION_STR "XXFFF"
```
where *XX* is the country code and *FFF* is the frequency of band in MHz.