-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from HuakeZhBo/smk_shell
implement shell and command demo
- Loading branch information
Showing
10 changed files
with
1,069 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
250 changes: 250 additions & 0 deletions
250
firmware/bl_mcu_sdk/examples/keyboard/sipeed_keyboard_68/bl702_flash_ble.ld
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,250 @@ | ||
/**************************************************************************************** | ||
* @file bl702_flash.ld | ||
* | ||
* @brief This file is the map file (gnuarm or armgcc). | ||
* | ||
* Copyright (C) BouffaloLab 2021 | ||
* | ||
**************************************************************************************** | ||
*/ | ||
|
||
/* configure the CPU type */ | ||
OUTPUT_ARCH( "riscv" ) | ||
/* link with the standard c library */ | ||
/* INPUT(-lc) */ | ||
/* link with the standard GCC library */ | ||
/* INPUT(-lgcc) */ | ||
/* configure the entry point */ | ||
ENTRY(_enter) | ||
|
||
StackSize = 0x1000; /* 4KB */ | ||
HeapSize = 0x1000; /* 4KB */ | ||
__EM_SIZE = DEFINED(ble_controller_init) ? 8K : 0K; | ||
|
||
MEMORY | ||
{ | ||
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 1024K | ||
itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 16K | ||
dtcm_memory (rx) : ORIGIN = 0x42018000, LENGTH = 32K | ||
ram_memory (!rx) : ORIGIN = 0x42020000, LENGTH = 32K | ||
rsvd_memory (!rx) : ORIGIN = 0x42028000, LENGTH = 1K | ||
ram2_memory (!rx) : ORIGIN = 0x42028400, LENGTH = (31K - __EM_SIZE) | ||
} | ||
|
||
SECTIONS | ||
{ | ||
PROVIDE(__metal_chicken_bit = 0); | ||
|
||
.text : | ||
{ | ||
. = ALIGN(4); | ||
__text_code_start__ = .; | ||
|
||
KEEP (*(.text.metal.init.enter)) | ||
KEEP (*(SORT_NONE(.init))) | ||
/* section information for finsh shell */ | ||
/*. = ALIGN(4); | ||
_shell_command_start = .; | ||
KEEP(*(shellCommand)) | ||
_shell_command_end = .;*/ | ||
/* section information for shell */ | ||
. = ALIGN(4); | ||
__fsymtab_start = .; | ||
KEEP(*(FSymTab)) | ||
__fsymtab_end = .; | ||
|
||
. = ALIGN(4); | ||
__vsymtab_start = .; | ||
KEEP(*(VSymTab)) | ||
__vsymtab_end = .; | ||
|
||
/* section information for usb desc */ | ||
. = ALIGN(4); | ||
_usb_desc_start = .; | ||
KEEP(*(usb_desc)) | ||
. = ALIGN(4); | ||
_usb_desc_end = .; | ||
|
||
*(.text) | ||
*(.text.*) | ||
|
||
/*put .rodata**/ | ||
*(EXCLUDE_FILE( *bl702_glb.o \ | ||
*bl702_pds.o \ | ||
*bl702_common.o \ | ||
*bl702_sf_cfg.o \ | ||
*bl702_sf_ctrl.o \ | ||
*bl702_sflash.o \ | ||
*bl702_xip_sflash.o \ | ||
*bl702_ef_ctrl.o) .rodata*) | ||
*(.rodata) | ||
*(.rodata.*) | ||
|
||
*(.srodata) | ||
*(.srodata.*) | ||
|
||
_bt_gatt_service_static_list_start = .; | ||
KEEP(*(SORT_BY_NAME("._bt_gatt_service_static.static.*"))) | ||
_bt_gatt_service_static_list_end = .; | ||
_bt_l2cap_fixed_chan_list_start = .; | ||
KEEP(*(SORT_BY_NAME("._bt_l2cap_fixed_chan.static.*"))) | ||
_bt_l2cap_fixed_chan_list_end = .; | ||
|
||
. = ALIGN(4); | ||
__text_code_end__ = .; | ||
} > xip_memory | ||
|
||
. = ALIGN(4); | ||
__itcm_load_addr = .; | ||
|
||
.itcm_region : AT (__itcm_load_addr) | ||
{ | ||
. = ALIGN(4); | ||
__tcm_code_start__ = .; | ||
|
||
*(.tcm_code) | ||
*(.tcm_const) | ||
*(.sclock_rlt_code) | ||
*(.sclock_rlt_const) | ||
|
||
*bl702_glb.o*(.rodata*) | ||
*bl702_pds.o*(.rodata*) | ||
*bl702_common.o*(.rodata*) | ||
*bl702_sf_cfg.o*(.rodata*) | ||
*bl702_sf_ctrl.o*(.rodata*) | ||
*bl702_sflash.o*(.rodata*) | ||
*bl702_xip_sflash.o*(.rodata*) | ||
*bl702_ef_ctrl.o*(.rodata*) | ||
|
||
. = ALIGN(4); | ||
__tcm_code_end__ = .; | ||
} > itcm_memory | ||
|
||
__dtcm_load_addr = __itcm_load_addr + SIZEOF(.itcm_region); | ||
|
||
.dtcm_region : AT (__dtcm_load_addr) | ||
{ | ||
. = ALIGN(4); | ||
__tcm_data_start__ = .; | ||
|
||
*(.tcm_data) | ||
/* *finger_print.o(.data*) */ | ||
|
||
. = ALIGN(4); | ||
__tcm_data_end__ = .; | ||
} > dtcm_memory | ||
|
||
/* .heap_dummy section doesn't contains any symbols. It is only | ||
* used for linker to calculate size of heap sections, and assign | ||
* values to heap symbols later */ | ||
.heap_dummy (NOLOAD): | ||
{ | ||
. = ALIGN(0x4); | ||
. = . + HeapSize; | ||
. = ALIGN(0x4); | ||
} > dtcm_memory | ||
|
||
_HeapBase = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory) - StackSize - HeapSize; | ||
_HeapSize = HeapSize; | ||
|
||
/* Check if data + heap + stack exceeds RAM limit */ | ||
ASSERT(_HeapBase >= __tcm_data_end__, "region RAM overflowed with stack") | ||
|
||
/*************************************************************************/ | ||
/* .stack_dummy section doesn't contains any symbols. It is only | ||
* used for linker to calculate size of stack sections, and assign | ||
* values to stack symbols later */ | ||
.stack_dummy (NOLOAD): | ||
{ | ||
. = ALIGN(0x4); | ||
. = . + StackSize; | ||
. = ALIGN(0x4); | ||
} > dtcm_memory | ||
|
||
/* Set stack top to end of RAM, and stack limit move down by | ||
* size of stack_dummy section */ | ||
__StackTop = ORIGIN(dtcm_memory) + LENGTH(dtcm_memory); | ||
PROVIDE( __freertos_irq_stack_top = __StackTop); | ||
__StackLimit = __StackTop - SIZEOF(.stack_dummy); | ||
|
||
/* Check if data + heap + stack exceeds RAM limit */ | ||
ASSERT(__StackLimit >= __tcm_data_end__, "region RAM overflowed with stack") | ||
/*************************************************************************/ | ||
|
||
__system_ram_load_addr = __dtcm_load_addr + SIZEOF(.dtcm_region); | ||
|
||
.system_ram_data_region : AT (__system_ram_load_addr) | ||
{ | ||
. = ALIGN(4); | ||
__system_ram_data_start__ = .; | ||
|
||
*(.system_ram) | ||
|
||
. = ALIGN(4); | ||
__system_ram_data_end__ = .; | ||
} > ram_memory | ||
|
||
__ram_load_addr = __system_ram_load_addr + SIZEOF(.system_ram_data_region); | ||
|
||
/* Data section */ | ||
RAM_DATA : AT (__ram_load_addr) | ||
{ | ||
. = ALIGN(4); | ||
__ram_data_start__ = .; | ||
|
||
PROVIDE( __global_pointer$ = . + 0x800 ); | ||
|
||
*(.data) | ||
*(.data.*) | ||
*(.sdata) | ||
*(.sdata.*) | ||
*(.sdata2) | ||
*(.sdata2.*) | ||
|
||
. = ALIGN(4); | ||
__ram_data_end__ = .; | ||
} > ram_memory | ||
|
||
.bss (NOLOAD) : | ||
{ | ||
. = ALIGN(4); | ||
__bss_start__ = .; | ||
|
||
*(.bss*) | ||
*(.sbss*) | ||
*(COMMON) | ||
|
||
. = ALIGN(4); | ||
__bss_end__ = .; | ||
} > ram_memory | ||
|
||
.noinit_data (NOLOAD) : | ||
{ | ||
. = ALIGN(4); | ||
__noinit_data_start__ = .; | ||
|
||
*(.noinit_data*) | ||
|
||
. = ALIGN(4); | ||
__noinit_data_end__ = .; | ||
} > ram_memory | ||
|
||
.heap (NOLOAD): | ||
{ | ||
. = ALIGN(4); | ||
__HeapBase = .; | ||
|
||
/*__end__ = .;*/ | ||
/*end = __end__;*/ | ||
KEEP(*(.heap*)) | ||
|
||
. = ALIGN(4); | ||
__HeapLimit = .; | ||
} > ram_memory | ||
__HeapLimit = ORIGIN(ram_memory) + LENGTH(ram_memory); | ||
|
||
PROVIDE( _heap_start = ORIGIN(ram2_memory) ); | ||
PROVIDE( _heap_size = LENGTH(ram2_memory) ); | ||
|
||
} | ||
|
13 changes: 13 additions & 0 deletions
13
firmware/bl_mcu_sdk/examples/keyboard/sipeed_keyboard_68/include/shell_config.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef __SHELL_CONFIG_H__ | ||
#define __SHELL_CONFIG_H__ | ||
|
||
#define SHELL_NAME "sipeed" | ||
#define SHELL_CONSOLEBUF_SIZE 128 | ||
|
||
#define SHELL_HISTORY_LINES 5 | ||
#define SHELL_CMD_SIZE 50 | ||
#define SHELL_ARG_NUM 8 | ||
|
||
//#define SHELL_USING_FS | ||
|
||
#endif |
20 changes: 20 additions & 0 deletions
20
firmware/bl_mcu_sdk/examples/keyboard/sipeed_keyboard_68/include/smk_command.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "smk_shell.h" | ||
|
||
void hellowd() | ||
{ | ||
acm_printf("hello World\r\n"); | ||
} | ||
|
||
int echo(int argc, char *argv[]) | ||
{ | ||
acm_printf("%dparameter(s)\r\n", argc); | ||
|
||
for (uint8_t i = 1; i < argc; i++) { | ||
acm_printf("%s\r\n", argv[i]); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
SHELL_CMD_EXPORT(hellowd, hellowd test) | ||
SHELL_CMD_EXPORT(echo, echo test) |
Oops, something went wrong.