I have spent a lot of time trying to activate command shell for my stm32f100 board.
I have use USART1 to connect the chip to a computer. Any chprintf() calls work fine but shell keeps a silence.
All shell related code is separated in cmd.{h.c} files:
Code: Select all
/*
* CMD.H
*/
#include <ch.h>
#define SHELL_SD SD1
#define STDOUT_SD SHELL_SD
#define STDIN_SD SHELL_SD
#define SHELL_WA_SIZE THD_WA_SIZE(2048)
void cmd_init(void);
void cmd_respawn(void);
/*
* CMD.C
*/
#include <hal.h>
#include <shell.h>
#include <chprintf.h>
#include "cmd.h"
static Thread* th_shell;
static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]);
static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]);
static const ShellCommand commands[] = {
{"mem", (shellcmd_t) cmd_mem},
{"threads", (shellcmd_t) cmd_threads},
{NULL, NULL}
};
static const ShellConfig config = {
(BaseSequentialStream*) &SHELL_SD, commands
};
void cmd_init(void) {
th_shell = NULL;
shellInit();
}
void cmd_respawn(void) {
if (!th_shell) {
th_shell = shellCreate(&config,
SHELL_WA_SIZE,
NORMALPRIO);
} else if (chThdTerminated(th_shell)) {
chThdRelease(th_shell);
th_shell = NULL;
}
}
static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) { .. }
static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) { .. }In main.c I did the following:
Code: Select all
#include <ch.h>
#include <hal.h>
#include <chprintf.h>
#include "cmd.h"
#include "display.h"
int main(void) {
halInit();
chSysInit();
sdStart(&SHELL_SD, NULL);
cmd_init();
chprintf((BaseSequentialStream*) &SHELL_SD, "started\n");
while (!chThdShouldTerminate()) {
cmd_respawn();
chThdSleepMilliseconds(1000);
}
}In Makefile I did the folloing:
Code: Select all
CSRC = .. \
$(CHIBIOS)/os/various/evtimer.c \
$(CHIBIOS)/os/various/shell.c \
$(CHIBIOS)/os/various/syscalls.c \
$(CHIBIOS)/os/various/chprintf.c \
main.c cmd.cIn mcuconf.h:
Code: Select all
#define STM32_SERIAL_USE_USART1 TRUEAlso, I have enabled CH_USE_MALLOC_HEAP and CH_USE_DYNAMIC.
But I still see no ChibiOS prompt in a terminal:
Code: Select all
$ miniterm.py -e -p /dev/ttyUSB0
--- Miniterm on /dev/ttyUSB0: 9600,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
startedWhere I did a mistake?