【ST NUCLEO-U5A5ZJ-Q开发板测评】移植TobudOS
<div class='showpostmsg'><p>1、用stm32CubeMax新建Keil工程LED工程,也可以用示例中的LED工程进行创建。</p><p>2、在当前工程目录下面新建一个用于存放OS的文件夹,把TobudOS源码中的arch、kernel、osal拷入工程之中,并且新建一个TOS_Config用于存放配置文件。</p>
<p> 3、在工程中新建三个工程分组OS/arch、OS/kernel、OS/config</p>
<p> </p>
<p>4、把kernel\core下面所有的C文件加入工程之中。</p>
<p>5、把arch/arm/arm-v8m/cortex-m33/armcc下面的prot_C、ports.S加入工程中,以及把arch/arm/arm-v8m\common下面的tos_cpu.c、tos_fault.c,以及osal\cmsis_os目录下的cmsis_os、os_tick.c加入工程组中。把config下面的tos_config.h也加入CONFIG组之中。</p>
<p>6、添回头文件路径:</p>
<p> </p>
<p>7、打开stm32u5xx_it.c,加入#include "tos_k.h "、#include "stm32u5xx_it.h"头文件的引用。注释掉PendSV_Handler,或者用__weak。</p>
<p>8、添加心跳到systickhandle中:</p>
<pre>
<code>void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
/* USER CODE BEGIN SysTick_IRQn 1 */
if(tos_knl_is_running()) {
tos_knl_irq_enter();
tos_tick_handler();
tos_knl_irq_leave();
}
/* USER CODE END SysTick_IRQn 1 */
}</code></pre>
<p>9、打开配置文件,修改内容如下:</p>
<pre>
<code>#ifndef _TOS_CONFIG_H_
#define_TOS_CONFIG_H_
#include "main.h"
#include "stm32u5xx.h" // 目标芯片头文件,视特定芯片而定
#include <stdio.h>
#define TOS_CFG_TASK_PRIO_MAX 10u
#define TOS_CFG_ROUND_ROBIN_EN 1u
#define TOS_CFG_OBJECT_VERIFY_EN 1u
#define TOS_CFG_OBJ_DYNAMIC_CREATE_EN 1u
#define TOS_CFG_EVENT_EN 1u
#define TOS_CFG_MMBLK_EN 1u
#define TOS_CFG_MMHEAP_EN 1u
#define TOS_CFG_MMHEAP_DEFAULT_POOL_SIZE 0x8000
#define TOS_CFG_MUTEX_EN 1u
#define TOS_CFG_TIMER_EN 1u
#define TOS_CFG_PWR_MGR_EN 0u
#define TOS_CFG_TICKLESS_EN 0u
#define TOS_CFG_SEM_EN 1u
#define TOS_CFG_TASK_STACK_DRAUGHT_DEPTH_DETACT_EN 1u
#define TOS_CFG_FAULT_BACKTRACE_EN 0u
#define TOS_CFG_IDLE_TASK_STK_SIZE 512u
#define TOS_CFG_CPU_TICK_PER_SECOND 1000u
#define TOS_CFG_CPU_CLOCK (SystemCoreClock)
#define TOS_CFG_TIMER_AS_PROC 1u
#define TOS_CFG_MAIL_QUEUE_EN 1u
#endif
</code></pre>
<p>10、在main.c中添加测试函数如下:</p>
<pre>
<code>/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "tos_k.h "
#include "cmsis_os.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
static GPIO_InitTypeDefGPIO_InitStruct;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void SystemPower_Config(void);
/* USER CODE BEGIN PFP */
//task1
#define TASK1_STK_SIZE 512
void task1(void *pdata);
osThreadDef(task1, osPriorityNormal, 1, TASK1_STK_SIZE);
//task2
#define TASK2_STK_SIZE 512
void task2(void *pdata);
osThreadDef(task2, osPriorityNormal, 1, TASK2_STK_SIZE);
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void task1(void *pdata)
{
while(1)
{
HAL_GPIO_TogglePin(LED1_GPIO_PORT, LED1_PIN);
osDelay(200);
}
}
void task2(void *pdata) {
while(1) {
HAL_GPIO_TogglePin(LED2_GPIO_PORT, LED2_PIN);
osDelay(1000);
}
}
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* STM32U5xx HAL library initialization:
- Configure the Flash prefetch
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 3
- Low Level Initialization
*/
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* Configure the System Power */
SystemPower_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_ICACHE_Init();
/* USER CODE BEGIN 2 */
/* -1- Enable GPIO Clock (to be able to program the configuration registers) */
LED1_GPIO_CLK_ENABLE();
LED2_GPIO_CLK_ENABLE();
/* -2- Configure IO in output push-pull mode to drive external LEDs */
GPIO_InitStruct.Mode= GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull= GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pin = LED1_PIN;
HAL_GPIO_Init(LED1_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LED2_PIN;
HAL_GPIO_Init(LED2_GPIO_PORT, &GPIO_InitStruct);
osKernelInitialize();
osThreadCreate(osThread(task1),NULL);
osThreadCreate(osThread(task2),NULL);
osKernelStart();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(LED1_GPIO_PORT, LED1_PIN);
/* Insert delay 100 ms */
HAL_Delay(100);
HAL_GPIO_TogglePin(LED2_GPIO_PORT, LED2_PIN);
/* Insert delay 100 ms */
HAL_Delay(100);
}
/* USER CODE END 3 */
}</code></pre>
<p>11、下载到开发板后就可以实现两个任务来控制两个不同的任务来翻转LED1与LED2了。</p>
<p>【总结】</p>
<p>TobudOS是最近加入开源基金会的开源系统。实现非常小的内存与ROM的实时操作系统。</p>
<p>附工程源代码:</p>
<div></div>
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <p>移植TobudOS,来实现非常小的内存与ROM的实时操作系统,是不是有一点小难度呢</p>
<p>看了下官方的说明,很小的实现呢,最小内核:RAM 0.6KB,ROM 1.8KB 典型 LoraWAN 及传感器应用:RAM 3.3KB,ROM 12KB</p>
<p> </p>
Jacktang 发表于 2024-2-13 10:25
移植TobudOS,来实现非常小的内存与ROM的实时操作系统,是不是有一点小难度呢
<p>很简单的,但是是新东西,原来推广不是很成功,现在也很小众。</p>
<p>一寸小一寸巧,移植系统的我都是来仰望的!</p>
HonestQiao 发表于 2024-2-18 18:00
一寸小一寸巧,移植系统的我都是来仰望的!
<p>国产的OS,相比帮主大佬你现在用的zephry,还差了许多。希望它能成长更多,让更多人了解、使用它。</p>
<p>学习学习</p>
<p>大佬牛逼 学习了</p>
常见泽1 发表于 2024-2-24 23:03
大佬牛逼 学习了
<p>感谢大佬来捧场,我还得继续向前辈您学习,我经常拜读你的帖子,受益匪浅呀!</p>
页:
[1]