Skip to content

Commit

Permalink
Add bk7231 to alios.
Browse files Browse the repository at this point in the history
  • Loading branch information
crazymouse2018 committed Apr 27, 2018
1 parent 14f23d0 commit fd49582
Show file tree
Hide file tree
Showing 139 changed files with 76,597 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@ $Recycle.Bin
.sconsign.dblite
ckhobbit*.map
projects/autogen/*
# source sight project files
*.IAB
*.IAD
*.IMB
*.IMD
*.PFI
*.PO
*.PR
*.PRI
*.PS
*.SearchResults
*.WK3
35 changes: 35 additions & 0 deletions board/bk7231devkitc/bk7231devkitc.ld.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Script for GNU linker.
* Describes layout of sections, location of stack.
*
* In this case vectors are at location 0 (reset @ 0x08)
*
* +------------+ 0x00400000
* data |
* end
* |(heap) |
* . .
* . .
* |(heap limit)|
*
* |- - - - - - |
* stack bottom 256k
* +------------+
*
* +------------+ 0x0000000
* |vectors |
* | |
* |------------+
* |text |
* |data |
* | | 1024k
* +------------+
*/


/* Split memory into area for vectors and ram */
MEMORY
{
flash (rx) : ORIGIN = 0x00000000, LENGTH = 2M
ram (rwx): ORIGIN = 0x00400020, LENGTH = 256k - 32
}
29 changes: 29 additions & 0 deletions board/bk7231devkitc/bk7231devkitc.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
NAME := board_bk7231

JTAG := jlink

$(NAME)_TYPE := kernel
MODULE := BK7231
HOST_ARCH := ARM968E-S
HOST_MCU_FAMILY := bk7231
SUPPORT_BINS := no

$(NAME)_SOURCES := board.c

GLOBAL_INCLUDES += .
GLOBAL_DEFINES += STDIO_UART=1

CONFIG_SYSINFO_PRODUCT_MODEL := ALI_AOS_BK7231
CONFIG_SYSINFO_DEVICE_NAME := BK7231


GLOBAL_CFLAGS += -DSYSINFO_PRODUCT_MODEL=\"$(CONFIG_SYSINFO_PRODUCT_MODEL)\"
GLOBAL_CFLAGS += -DSYSINFO_DEVICE_NAME=\"$(CONFIG_SYSINFO_DEVICE_NAME)\"
#GLOBAL_CFLAGS += -DSYSINFO_KERNEL_VERSION=\"$(CONFIG_SYSINFO_KERNEL_VERSION)\"
#GLOBAL_CFLAGS += -DSYSINFO_APP_VERSION=\"$(CONFIG_SYSINFO_APP_VERSION)\"

GLOBAL_LDS_INCLUDES += $(SOURCE_ROOT)/board/bk7231devkitc/bk7231devkitc.ld.S

# Extra build target in aos_standard_targets.mk, include bootloader, and copy output file to eclipse debug file (copy_output_for_eclipse)
EXTRA_TARGET_MAKEFILES += $(MAKEFILES_PATH)/aos_standard_targets.mk
EXTRA_TARGET_MAKEFILES += $(SOURCE_ROOT)/platform/mcu/$(HOST_MCU_FAMILY)/gen_crc_bin.mk
186 changes: 186 additions & 0 deletions board/bk7231devkitc/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/

#include "hal/soc/soc.h"
#include <aos/kernel.h>
#include <aos/aos.h>

/* Logic partition on flash devices */
const hal_logic_partition_t hal_partitions[] =
{
[HAL_PARTITION_BOOTLOADER] =
{
.partition_owner = HAL_FLASH_EMBEDDED,
.partition_description = "Bootloader",
.partition_start_addr = 0x00000,
.partition_length = 0x10000, //64k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[HAL_PARTITION_APPLICATION] =
{
.partition_owner = HAL_FLASH_EMBEDDED,
.partition_description = "Application",
.partition_start_addr = 0x00000,//phy is 0x11000
.partition_length = 0xAF000, //700k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[HAL_PARTITION_PARAMETER_1] =
{
.partition_owner = HAL_FLASH_EMBEDDED,
.partition_description = "PARAMETER1",
.partition_start_addr = 0x100000,
.partition_length = 0x1000, // 4k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[HAL_PARTITION_PARAMETER_2] =
{
.partition_owner = HAL_FLASH_EMBEDDED,
.partition_description = "PARAMETER2",
.partition_start_addr = 0x101000,
.partition_length = 0x2000, // 8k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[HAL_PARTITION_OTA_TEMP] =
{
.partition_owner = HAL_FLASH_EMBEDDED,
.partition_description = "OTA Storage",
.partition_start_addr = 0x103000,
.partition_length = 0xAF000, //700k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[HAL_PARTITION_PARAMETER_3] =
{
.partition_owner = HAL_FLASH_EMBEDDED,
.partition_description = "PARAMETER3",
.partition_start_addr = 0x1B2000,
.partition_length = 0x1000, // 4k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[HAL_PARTITION_PARAMETER_4] =
{
.partition_owner = HAL_FLASH_EMBEDDED,
.partition_description = "PARAMETER4",
.partition_start_addr = 0x1B3000,
.partition_length = 0x1000, // 4k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
[HAL_PARTITION_RF_FIRMWARE] =
{
.partition_owner = HAL_FLASH_EMBEDDED,
.partition_description = "RF parameter",
.partition_start_addr = 0x1B4000,// rf parameter is 0x1A2000
.partition_length = 0x1000, // 4k bytes
.partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN,
},
};


#define KEY_BOOT 15
#define KEY_PS 14
static uint64_t elink_time = 0;
static uint64_t ps_time = 0;
static gpio_dev_t gpio_key_boot;
static gpio_dev_t gpio_key_ps;

static void key_poll_func(void *arg)
{
uint32_t level;
uint64_t diff;

hal_gpio_input_get(&gpio_key_boot, &level);

if (level == 0) {
aos_post_delayed_action(10, key_poll_func, NULL);
} else {
diff = aos_now_ms() - elink_time;
if (diff > 2000) { /* long press */
elink_time = 0;
aos_post_event(EV_KEY, CODE_BOOT, VALUE_KEY_LTCLICK);
} else if (diff > 40) { /* short press */
elink_time = 0;
aos_post_event(EV_KEY, CODE_BOOT, VALUE_KEY_CLICK);
} else {
aos_post_delayed_action(10, key_poll_func, NULL);
}
}
}

static void key_ps_func(void *arg)
{
#if 0
uint32_t level;
uint64_t diff;

hal_gpio_input_get(&gpio_key_ps, &level);

if (level == 0) {
aos_post_delayed_action(10, key_ps_func, NULL);
} else {
diff = aos_now_ms() - ps_time;
if (diff > 40) {
ps_time = 0;
aos_post_event(EV_KEY, CODE_BOOT, VALUE_KEY_PSCLICK);

}else if (diff > 2000) { /* short press */
elink_time = 0;
aos_post_event(EV_KEY, CODE_BOOT, VALUE_KEY_LPSCLICK);
} else {
aos_post_delayed_action(10, key_ps_func, NULL);
}
}
#endif
}

static void key_proc_work(void *arg)
{
aos_schedule_call(key_poll_func, NULL);
}

static void key_ps_work(void *arg)
{
aos_schedule_call(key_ps_func, NULL);
}

static void handle_elink_key(void *arg)
{
uint32_t gpio_value;

hal_gpio_input_get(&gpio_key_boot, &gpio_value);
if (gpio_value == 0 && elink_time == 0) {
elink_time = aos_now_ms();
aos_loop_schedule_work(0, key_proc_work, NULL, NULL, NULL);
}
}
static void handle_ps_key(void *arg)
{
uint32_t gpio_value;

hal_gpio_input_get(&gpio_key_ps, &gpio_value);
if (gpio_value == 0 && ps_time == 0) {
ps_time = aos_now_ms();
aos_loop_schedule_work(0, key_ps_work, NULL, NULL, NULL);
}
}

void board_init(void)
{
gpio_key_boot.port = KEY_BOOT;
gpio_key_boot.config = INPUT_PULL_UP;
hal_gpio_init(&gpio_key_boot);

hal_gpio_clear_irq(&gpio_key_boot);
hal_gpio_enable_irq(&gpio_key_boot, IRQ_TRIGGER_FALLING_EDGE, handle_elink_key, NULL);

gpio_key_ps.port = KEY_PS;
gpio_key_ps.config = INPUT_PULL_UP;
hal_gpio_init(&gpio_key_ps);

hal_gpio_clear_irq(&gpio_key_ps);
hal_gpio_enable_irq(&gpio_key_ps, IRQ_TRIGGER_FALLING_EDGE, handle_ps_key, NULL);
}

int board_cli_init(void)
{
}

14 changes: 14 additions & 0 deletions board/bk7231devkitc/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/

#define HARDWARE_REVISION "V1.0"
#define MODEL "BK7231"

#ifdef BOOTLOADER
#define STDIO_UART 1
#define STDIO_UART_BUADRATE 115200
#else
#define STDIO_UART 1
#define STDIO_UART_BUADRATE 115200
#endif
Loading

0 comments on commit fd49582

Please sign in to comment.