- The ARM port is now building (Not on the buildbot though. Have to build the multilib ARM GCC first)
It's just switches down to IDLE for for. Interrupts are coming in a couple of days.
- A new tiny example added to handle systems with small RAM/ROM footprint.
It make very little use of the clib.
- Lauterbach T32 scripts now updated so that they can be used anyone?
The wiki is also updated.
- Size configuration possible for RAMLOG and HEAP.
- Support for SIMPLE_PRINTF is now optional.
\r
#if !defined (STM32F10X_LD) && !defined (STM32F10X_MD) && !defined (STM32F10X_HD) && !defined (STM32F10X_CL)\r
/* #define STM32F10X_LD */ /*!< STM32F10X_LD: STM32 Low density devices */\r
- /* #define STM32F10X_MD */ /*!< STM32F10X_MD: STM32 Medium density devices */\r
+ #define STM32F10X_MD /*!< STM32F10X_MD: STM32 Medium density devices */\r
/* #define STM32F10X_HD */ /*!< STM32F10X_HD: STM32 High density devices */\r
- #define STM32F10X_CL /*!< STM32F10X_CL: STM32 Connectivity line devices */\r
+ /* #define STM32F10X_CL */ /*!< STM32F10X_CL: STM32 Connectivity line devices */\r
#endif\r
/* Tip: To avoid modifying this file each time you need to switch between these\r
devices, you can define the device in your toolchain compiler preprocessor.\r
\r
void os_arch_first_call( void )\r
{\r
- // TODO: make swicth here... for now just call func.\r
+ // TODO: make switch here... for now just call func.\r
os_sys.curr_pcb->entry();\r
}\r
\r
\r
/* Set LR to start function */\r
if( pcb->proc_type == PROC_EXTENDED ) {\r
- context[C_LR_OFF/4] = (uint32_t)os_proc_start_extended;\r
+ context[VGPR_LR_OFF/4] = (uint32_t)os_proc_start_extended;\r
} else if( pcb->proc_type == PROC_BASIC ) {\r
- context[C_LR_OFF/4] = (uint32_t)os_proc_start_basic;\r
+ context[VGPR_LR_OFF/4] = (uint32_t)os_proc_start_basic;\r
}\r
// os_arch_setup_context_asm(pcb->stack.curr,NULL);\r
}\r
.fpu softvfp\r
.thumb\r
\r
- .global os_arch_swap_context_to\r
- .global os_arch_swap_context\r
.section .text\r
/* r0 - pcb for old task\r
* r1 pcb for new task\r
* ---------- <- JABBA\r
*\r
*/\r
+ .global os_arch_swap_context\r
+ .type os_arch_swap_context_to, %function\r
os_arch_swap_context:\r
mov r0, sp\r
- push {r0,r4-r8,r10,r11,lr}\r
-\r
+ push {r4-r8,r10,r11,lr}\r
\r
// Store c-frame\r
sub.w sp,sp,#C_SIZE\r
+\r
mov.w r4,#SC_PATTERN\r
+ str r4,[sp,#C_CONTEXT_OFFS]\r
+ str r0,[sp,#C_SP_OFF]\r
+ // ---> We have saved NVGPR+C\r
\r
- str r4,[sp,#4]\r
// store old stack for old task\r
str sp,[r0,#PCB_STACK_CURR_P]\r
+\r
+// R1 - new PCB\r
+ .global os_arch_swap_context_to\r
+ .type os_arch_swap_context_to, %function\r
os_arch_swap_context_to:\r
+\r
// Get stack for new task\r
- ldr sp,[r1,#PCB_STACK_CURR_P]\r
+ ldr r2,[r1,#PCB_STACK_CURR_P]\r
+ msr msp,r2\r
\r
// TODO: Fix this for all arch's..call pre,post hooks. Done here or after?\r
// Set new current pcb\r
str r1,[r5,#SYS_CURR_PCB_P]\r
\r
// Restore C context\r
- ldr r6,[sp,#4]\r
+ ldr r6,[sp,#C_CONTEXT_OFFS]\r
cmp r6,#SC_PATTERN\r
beq os_sc_restore\r
cmp r6,#LC_PATTERN\r
\r
os_sc_restore:\r
add.w sp,sp,#C_SIZE\r
+\r
pop {r4-r8,r10,r11,lr}\r
// ehh, we are in handler mode so a bx instruction works here\r
bx lr\r
\r
os_lc_restore:\r
add.w sp,sp,#C_SIZE\r
- pop {r4-r8,r10,r11,lr}\r
+ pop {lr,r11,r10,r8,r7,r6,r5,r4}\r
// ehh, we are in handler mode so a bx instruction works here\r
bx lr\r
\r
\r
typedef IRQn_Type IrqType;\r
\r
-#define NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS (OTG_FS_IRQn+15)\r
+#define NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS (USBWakeUp_IRQn+15)\r
\r
typedef enum {\r
CPU_0=0,\r
/* Large context (interrupt) */\r
#define SAVE_ALL_GPR(_x,_y)\r
#define RESTORE_ALL_GPR(_x,_y)\r
-\r
+
+#if 0\r
#define C_SIZE 16\r
#define C_SP_OFF 0\r
#define C_CONTEXT_OFF 4\r
#define C_CR_OFF 12\r
\r
#define C_CONTEXT_OFFS 10\r
+#endif
+
+// NVREGS: r4+r5+r6+r7+r8+r10+r11+lr = 8*4
+#define NVGPR_SIZE 32
+// VGPR: 9*4 = 36
+#define VGPR_SIZE 36
+// SP + context
+#define C_SIZE 8
+
+//...
+#define VGPR_LR_OFF (C_SIZE+28)
+#define C_CONTEXT_OFFS 4
+#define C_SP_OFF 0
+
\r
-#define SC_SIZE 32\r
+#define SC_SIZE (NVGPR_SIZE+C_SIZE)
\r
#if !defined(_ASSEMBLER_)\r
\r
* @retval None\r
*/\r
static void SetSysClock(void)\r
-{\r
+{
+#if !defined(CFG_SIMULATOR)\r
#ifdef SYSCLK_FREQ_HSE\r
SetSysClockToHSE();\r
#elif defined SYSCLK_FREQ_24MHz\r
SetSysClockTo56(); \r
#elif defined SYSCLK_FREQ_72MHz\r
SetSysClockTo72();\r
+#endif
#endif\r
\r
/* If none of the define above is enabled, the HSI is used as System clock\r
#endif /* STM32F10X_CL */\r
\r
/* Enable PLL */\r
- RCC->CR |= RCC_CR_PLLON;\r
-\r
+ RCC->CR |= RCC_CR_PLLON;
+
+
/* Wait till PLL is ready */\r
while((RCC->CR & RCC_CR_PLLRDY) == 0)\r
{\r
/* Select PLL as system clock source */\r
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));\r
RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL; \r
-\r
+
/* Wait till PLL is used as system clock source */\r
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08)\r
{\r
/*\r
Linker subscript for STM32F10x definitions with 512K Flash and 1024K RAM */\r
\r
+ENTRY(Reset_Handler)\r
+\r
/* Memory Spaces Definitions */\r
\r
MEMORY\r
{\r
- RAM (xrw) : ORIGIN = 0x68000000, LENGTH = 64K\r
- FLASH (rx) : ORIGIN = 0x0000000, LENGTH = 512K\r
+ /* ST32F103, 128K flash, 20K RAM */\r
+\r
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K\r
+ FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K\r
FLASHB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0\r
EXTMEMB0 (rx) : ORIGIN = 0x00000000, LENGTH = 0\r
EXTMEMB1 (rx) : ORIGIN = 0x00000000, LENGTH = 0\r
}\r
\r
/* higher address of the user mode stack */\r
-_estack = 0x68100000;\r
-\r
+_estack = 0x20005000;\r
\r
\r
/* include the sections management sub-script for FLASH mode */\r
* -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
\r
#include "types.h"\r
#include "Cpu.h"\r
// Note! stack.curr already points to where to save the context\r
\r
// Check that the stack size is enough\r
- #define STACK_SIZE_MIN (SC_SIZE + 16*2 )\r
+ #define STACK_SIZE_MIN (SC_SIZE + 16*2 )
+\r
if( pcb->stack.size < (STACK_SIZE_MIN) ) {\r
os_arch_stack_to_small(pcb, STACK_SIZE_MIN);\r
}\r
-\r
+
+#if 0\r
// Fill stack with a nice pattern STACK_PATTERN\r
{\r
uint8_t *p = pcb->stack.curr;\r
*p = STACK_PATTERN;\r
}\r
}\r
+#endif
\r
msr = MSR_EE;\r
\r
} else if( pcb->proc_type == PROC_BASIC ) {\r
context[C_LR_OFF/4] = (uint32_t)os_proc_start_basic;\r
}\r
- }\r
+ }
+
+ os_arch_stack_set_endmark(pcb);\r
}\r
\r
\r
\r
obj-$(CFG_PPC) += crt0.o\r
-vpath-$(CFG_ARM_CM3) += $(ARCH_PATH-y)kernel \r
-obj-$(CFG_ARM_CM3) += startup_stm32f10x_hd.o\r
+vpath-$(CFG_ARM_CM3) += $(ARCH_PATH-y)kernel\r
+# This is not true, md=medium,ld=low,hd=high \r
+obj-$(CFG_ARM_CM3) += startup_stm32f10x_md.o\r
obj-$(CFG_ARM_CM3) += system_stm32f10x.o\r
obj-$(CFG_ARM_CM3) += core_cm3.o\r
\r
\r
# Common\r
obj-y += xtoa.o\r
-obj-y += ramlog.o\r
-obj-y += printf.o\r
+obj-$(USE_RAMLOG) += ramlog.o\r
+obj-$(USE_PRINTF) += printf.o\r
VPATH += $(ROOTDIR)/common\r
\r
obj-y += newlib_port.o\r
ARCH_MCU=arm_cm3
# CFG (y/n) macros
-CFG=ARM ARM_CM3 BRD_ET_STM32_STAMP
+CFG=ARM ARM_CM3 BRD_ET_STM32_STAMP SIMULATOR
# What buildable modules does this board have,
# Needed by us
MOD_USE=KERNEL MCU
+
+# Use little head
+def-y += HEAPSIZE=600
# What buildable modules does this board have,
# default or private
-MOD_AVAIL+=KERNEL MCU GPT LIN CAN CANIF PORT DIO WDG WDGM T32_TERM PWM WINIDEA_TERM COM ADC DMA
+MOD_AVAIL+=KERNEL RAMLOG MCU GPT LIN CAN CANIF PORT DIO WDG WDGM T32_TERM PWM WINIDEA_TERM COM ADC DMA SIMPLE_PRINTF
# Needed by us
MOD_USE=KERNEL MCU
# What buildable modules does this board have,
# default or private
-MOD_AVAIL=KERNEL MCU GPT LIN CAN WDG WDGM T32_TERM WINIDEA_TERM
+MOD_AVAIL=KERNEL RAMLOG MCU GPT LIN CAN WDG WDGM T32_TERM WINIDEA_TERM SIMPLE_PRINTF
# Needed by us
MOD_USE=KERNEL MCU
# What buildable modules does this board have,
# default or private
-MOD_AVAIL+=KERNEL MCU GPT LIN CAN COM WDG WDGM T32_TERM WINIDEA_TERM
+MOD_AVAIL+=KERNEL RAMLOG MCU GPT LIN CAN COM WDG WDGM T32_TERM WINIDEA_TERM
# Needed by kernel
MOD_USE+=KERNEL MCU
# What buildable modules does this board have,
# default or private
-MOD_AVAIL=KERNEL MCU WDG WDGM PORT DIO WDG WDGM T32_TERM WINIDEA_TERM PWM CAN CANIF COM ADC DMA
+MOD_AVAIL=KERNEL RAMLOG MCU WDG WDGM PORT DIO WDG WDGM T32_TERM WINIDEA_TERM PWM CAN CANIF COM ADC DMA SIMPLE_PRINTF
# Needed by us
MOD_USE=KERNEL MCU
+
+++ /dev/null
-/* -------------------------------- Arctic Core ------------------------------
- * Arctic Core - the open source AUTOSAR platform http://arccore.com
- *
- * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
- *
- * This source code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by the
- * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- * -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
-
-
-/*\r
- * config.h\r
- *\r
- * Created on: 2009-jul-08\r
- * Author: mahi\r
- */\r
-\r
-#ifndef CONFIG_H_\r
-#define CONFIG_H_\r
-\r
-/* For makefile's only (used to get the directory search paths right) */\r
-#define ARCH mpc55xx\r
-#define ARCH_FAM ppc\r
-#define ARCH_MCU mpc5567\r
-/*\r
- * CPU and board\r
- */\r
-#define CFG_PPC 1\r
-#define CFG_BOOKE 1\r
-#define CFG_E200Z6 1\r
-#define CFG_MPC55XX 1\r
-#define CFG_MPC5567 1\r
-\r
-#define USE_KERNEL 1\r
-#define USE_MCU 1\r
-\r
-\r
-/*\r
- * Misc\r
- */\r
-//#define USE_T32_TERM 1\r
-//#define CFG_CONSOLE_T32 1\r
-#define USE_WINIDEA_TERM 1\r
-#define CFG_CONSOLE_WINIDEA 1\r
-\r
-#define USE_PROTECTIONHOOK 1\r
-#define USE_STARTUPHOOK 1\r
-#define USE_SHUTDOWNHOOK 1\r
-#define USE_ERRORHOOK 1\r
-#define USE_PRETASKHOOK 1\r
-#define USE_POSTTASKHOOK 1\r
-\r
-#endif /* CONFIG_H_ */\r
-\r
#include <sys/stat.h>\r
#include <sys/types.h>\r
#include <errno.h>\r
-#include <stdlib.h>\r
+#include <stdlib.h>
+#include "Ramlog.h"\r
//#include "clibsupport_gcc.h"\r
#if defined(CFG_ARM)
}\r
else\r
{
+#if defined(USE_RAMLOG)
/* RAMLOG support */\r
if(fd == FILE_RAMLOG) {\r
for (int i = 0; i < nbytes; i++) {\r
ramlog_chr (*(buf + i));\r
}\r
- }\r
+ }
+#endif\r
}\r
\r
return (nbytes);\r
extern char _end[];\r
\r
//static char *curbrk = _end;\r
-\r
+
+#ifndef HEAPSIZE\r
#define HEAPSIZE 16000\r
+#endif
unsigned char _heap[HEAPSIZE];\r
\r
caddr_t sbrk( int incr )\r
* -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
-
-//#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+#include "simple_printf.h"
#define BUF_SIZE 60
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
-
-
\r
#include <stdio.h>\r
-#include <stdarg.h>\r
+#include <stdarg.h>
+#include "simple_printf.h"\r
\r
-extern int simple_sprintf(char *, const char *format, ...);\r
-\r
-#define CONFIG_RAMLOG_SIZE 2000\r
+
+#ifndef CFG_RAMLOG_SIZE\r
+#define CFG_RAMLOG_SIZE 2000
+#endif\r
\r
-static unsigned char ramlog[CONFIG_RAMLOG_SIZE] __attribute__ ((section (".ramlog")));\r
+static unsigned char ramlog[CFG_RAMLOG_SIZE] __attribute__ ((section (".ramlog")));\r
static unsigned ramlog_curr __attribute__ ((section (".ramlog")));\r
static unsigned ramlog_session __attribute__ ((section (".ramlog")));\r
\r
\r
void ramlog_chr( char c ) {\r
ramlog[ramlog_curr++] = c;\r
- if( ramlog_curr >= 2000 ) {\r
+ if( ramlog_curr >= CFG_RAMLOG_SIZE ) {\r
ramlog_curr = 0;\r
}\r
}\r
void ramlog_init()\r
{\r
char buf[32];\r
- if( ramlog_curr>CONFIG_RAMLOG_SIZE)\r
+ if( ramlog_curr>CFG_RAMLOG_SIZE)\r
{\r
ramlog_curr = 0;\r
ramlog_session = 0;\r
\r
-MOD_USE+=KERNEL MCU T32_TERM\r
+MOD_USE+=KERNEL MCU T32_TERM RAMLOG SIMPLE_PRINTF\r
\r
* for more details.
* -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
-
-/*\r
- * Os_Cfg.c\r
- *\r
- * Created on: 15 jul 2009\r
- * Author: mahi\r
- */\r
-\r
#include <stdlib.h>\r
#include <stdint.h>\r
#include "os_config_macros.h"\r
* for more details.
* -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
-
\r
#include "Os.h"\r
#include "Mcu.h"\r
--- /dev/null
+\r
+MOD_USE+=KERNEL MCU T32_TERM\r
+\r
--- /dev/null
+/* -------------------------------- Arctic Core ------------------------------
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com
+ *
+ * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
+ *
+ * This source code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ * -------------------------------- Arctic Core ------------------------------*/
+
+#include <stdlib.h>\r
+#include <stdint.h>\r
+#include "os_config_macros.h"\r
+#include "Platform_Types.h"\r
+#include "Os.h" // includes Os_Cfg.h\r
+#include "kernel.h"\r
+#include "kernel_offset.h"\r
+#include "alist_i.h"\r
+#include "Mcu.h"\r
+\r
+extern void dec_exception( void );\r
+\r
+// atleast 1\r
+#define SERVICE_CNT 1\r
+\r
+GEN_TRUSTEDFUNCTIONS_LIST\r
+\r
+//--- APPLICATIONS ----\r
+\r
+GEN_APPLICATION_HEAD {\r
+\r
+ GEN_APPLICATON( 0,\r
+ "application_1",\r
+ true,\r
+ NULL,NULL,NULL , 0,0,0,0,0,0 )\r
+};\r
+\r
+// --- RESOURCES ---\r
+\r
+GEN_RESOURCE_HEAD {\r
+ GEN_RESOURCE(RES_SCHEDULER,RESOURCE_TYPE_STANDARD,0,0,0), // Standard resource..\r
+};\r
+\r
+//--- TASKS ----\r
+\r
+DECLARE_STACK(OsIdle,PRIO_STACK_SIZE);\r
+DECLARE_STACK(etask_1,PRIO_STACK_SIZE);\r
+DECLARE_STACK(etask_2,PRIO_STACK_SIZE);\r
+DECLARE_STACK(btask_3,PRIO_STACK_SIZE);\r
+\r
+GEN_TASK_HEAD {\r
+ GEN_ETASK( OsIdle,\r
+ 0,\r
+ true/*auto*/,\r
+ NULL/*tm*/,\r
+ APPLICATION_ID_application_1/*app*/,\r
+ NULL/*rsrc*/),\r
+\r
+ GEN_ETASK( etask_1,\r
+ 1,\r
+ true/*auto*/,\r
+ NULL/*tm*/,\r
+ APPLICATION_ID_application_1/*app*/,\r
+ NULL/*rsrc*/),\r
+\r
+ GEN_ETASK( etask_2,\r
+ 2,\r
+ true/*auto*/,\r
+ NULL/*tm*/,\r
+ APPLICATION_ID_application_1/*app*/,\r
+ NULL/*rsrc*/),\r
+\r
+\r
+ GEN_BTASK( btask_3,\r
+ 3,\r
+ false/*auto*/,\r
+ NULL/*tm*/,\r
+ APPLICATION_ID_application_1/*app*/,\r
+ NULL/*rsrc*/),\r
+};\r
+\r
+GEN_PCB_LIST()\r
+\r
+// --- INTERRUPTS ---\r
+\r
+uint8_t os_interrupt_stack[OS_INTERRUPT_STACK_SIZE] __attribute__ ((aligned (0x10)));\r
+\r
+// The vector table\r
+void * intc_vector_tbl[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] __attribute__ ((aligned (0x1000),section(".data")))= {\r
+};\r
+\r
+// The type of vector\r
+uint8 intc_type_tbl[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] = {\r
+};\r
+\r
+// --- COUNTERS ---\r
+GEN_COUNTER_HEAD {\r
+ GEN_COUNTER( OS_TICK_COUNTER,\r
+ "OS_TICK_COUNTER",\r
+ COUNTER_TYPE_HARD,\r
+ COUNTER_UNIT_NANO,\r
+ 0xffff,1,1,0 ),\r
+};\r
+\r
+// --- MESSAGES ---\r
+\r
+// --- ALARMS ---\r
+#define ALARM_USE\r
+\r
+GEN_ALARM_HEAD {\r
+ GEN_ALARM( 0,"Alarm1",OS_TICK_COUNTER,\r
+ 1,100,10,0, /*active,start,cycle,app_mask */\r
+ ALARM_ACTION_SETEVENT, TASK_ID_etask_1, 2, 0 ),\r
+};\r
+\r
+// --- SCHEDULETABLES ---\r
+\r
+// --- HOOKS ---\r
+\r
+GEN_HOOKS( StartupHook, ProtectionHook, ShutdownHook, ErrorHook, PreTaskHook, PostTaskHook )\r
+\r
+\r
+\r
+// --- MISC ---\r
+\r
+uint32 os_dbg_mask = \\r
+ D_MASTER_PRINT |\\r
+ D_ISR_MASTER_PRINT |\\r
+ D_RAMLOG |\\r
+ D_ISR_RAMLOG | D_TASK | D_ALARM;\r
+\r
+\r
+// | D_ALARM | D_TASK;\r
+\r
+\r
+#include "os_config_funcs.h"\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
--- /dev/null
+/* -------------------------------- Arctic Core ------------------------------
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com
+ *
+ * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
+ *
+ * This source code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ * -------------------------------- Arctic Core ------------------------------*/
+
+
+
+
+
+
+
+
+/*\r
+ * Os_Cfg.h\r
+ *\r
+ * Created on: 2008-dec-22\r
+ * Author: mahi\r
+ */\r
+\r
+#ifndef OS_CFG_H_\r
+#define OS_CFG_H_\r
+\r
+/* os_config.h */\r
+\r
+#define APPLICATION_ID_application_1 0\r
+#define APPLICATION_CNT 1\r
+\r
+#define TASK_ID_OsIdle 0\r
+#define TASK_ID_etask_1 1\r
+#define TASK_ID_etask_2 2\r
+#define TASK_ID_btask_3 3\r
+\r
+void etask_1( void );\r
+void etask_2( void );\r
+void btask_3( void );\r
+\r
+//#define TASK_ID_os_tick 8\r
+\r
+\r
+// OS_TICK_COUNTER located in Os.h\r
+\r
+// NOT GENERATED( for test system only )\r
+#define SYSTEM_COUNTER_PERIOD 100\r
+\r
+#define PRIO_STACK_SIZE 200\r
+#define OS_INTERRUPT_STACK_SIZE 200\r
+\r
+// Just define them if you want to use them.\r
+#undef ALARM_USE\r
+#undef SCHEDULETABLE_USE\r
+#undef MESSAGE_USE\r
+#undef EVENT_USE\r
+#undef SERVICE_USE\r
+\r
+#define EVENT_0 (1<<0)\r
+#define EVENT_1 (1<<1)\r
+#define EVENT_2 (1<<2)\r
+\r
+\r
+#endif /* OS_CFG_H_ */\r
--- /dev/null
+\r
+# Our object files\r
+obj-y += tiny.o\r
+# OS object files.\r
+obj-y += Os_Cfg.o\r
+\r
+VPATH += ..\r
+VPATH += ../config\r
+\r
+inc-y += ../config\r
+inc-y += $(ROOTDIR)/system/kernel/$(objdir)\r
+inc-y += $(ROOTDIR)/system/kernel/include\r
+\r
+# The more precise configuration, the higher preceedance.\r
+VPATH := ../config/$(BOARDDIR) ../config $(VPATH)\r
+inc-y := ../config/$(BOARDDIR) ../config $(inc-y)\r
+\r
+# Board object files\r
+include $(ROOTDIR)/boards/board_common.mk\r
+\r
+# libs needed by us \r
+libitem-y += $(ROOTDIR)/libs/libkernel_$(ARCH_MCU).a\r
+\r
+#linkfile\r
+ldcmdfile-y = -T $(ROOTDIR)/$(ARCH_PATH-y)/scripts/linkscript_gcc.ldf\r
+\r
+# What I want to build\r
+build-exe-y = simple.elf\r
+\r
+\r
+\r
+\r
+\r
--- /dev/null
+/* -------------------------------- Arctic Core ------------------------------
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com
+ *
+ * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
+ *
+ * This source code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ * -------------------------------- Arctic Core ------------------------------*/
+
+\r
+#include "Os.h"\r
+#include "Mcu.h"\r
+\r
+#define USE_DEBUG\r
+#include "Trace.h"\r
+\r
+// How many errors to keep in error log.\r
+#define ERROR_LOG_SIZE 20\r
+\r
+\r
+/**\r
+ * Just an example of a basic task.\r
+ */\r
+\r
+void btask_3( void ) {\r
+ StackInfoType si;\r
+ TaskType currTask;\r
+ dbg_printf("[%08d] btask_3 start\n", GetOsTick() );\r
+\r
+ GetTaskID(&currTask);\r
+ Os_GetStackInfo(currTask,&si);\r
+ dbg_printf("btask_3: Stack usage %d%%\n",OS_STACK_USAGE(&si));\r
+\r
+ TerminateTask();\r
+}\r
+\r
+/**\r
+ * An extended task is auto-started and is also triggered by an alarm\r
+ * that sets event 2.\r
+ */\r
+\r
+void etask_1( void ) {\r
+ volatile float tryFloatingPoint = 0.0F;\r
+ StackInfoType si;\r
+ TaskType currTask;\r
+\r
+\r
+ dbg_printf("etask_1 start\n");\r
+ for(;;) {\r
+ SetEvent(TASK_ID_etask_2,1);\r
+ WaitEvent(2);\r
+ ClearEvent(2);\r
+ tryFloatingPoint += 1.0F;\r
+ GetTaskID(&currTask);\r
+ Os_GetStackInfo(currTask,&si);\r
+ dbg_printf("etask_1: Stack usage %d%% \n",OS_STACK_USAGE(&si));\r
+\r
+ }\r
+}\r
+\r
+/**\r
+ * An extended task that receives events from someone\r
+ * and activates task: btask_3.
+ */\r
+void etask_2( void ) {\r
+ dbg_printf("etask_2 start\n");\r
+\r
+ for(;;) {\r
+ WaitEvent(1);\r
+ ClearEvent(1);\r
+ ActivateTask(TASK_ID_btask_3);\r
+ {\r
+ StackInfoType si;\r
+ TaskType currTask;\r
+ GetTaskID(&currTask);\r
+ Os_GetStackInfo(currTask,&si);\r
+ dbg_printf("etask_1: Stack usage %d%% \n",OS_STACK_USAGE(&si));\r
+ }\r
+ }\r
+}\r
+\r
+\r
+/*\r
+ * Functions that must be supplied by the example\r
+ */\r
+\r
+void OsIdle( void ) {\r
+ for(;;);\r
+}\r
+\r
+\r
+/* Global hooks */\r
+ProtectionReturnType ProtectionHook( StatusType FatalError ) {\r
+ dbg_printf("## ProtectionHook\n");\r
+ return PRO_KILLAPPL;\r
+}\r
+\r
+void StartupHook( void ) {\r
+ uint32_t sys_freq = McuE_GetSystemClock();\r
+\r
+ dbg_printf("## StartupHook\n");\r
+\r
+ dbg_printf("Sys clock %d Hz\n",sys_freq);\r
+ Frt_Init();\r
+ Frt_Start(sys_freq/1000);\r
+}\r
+\r
+void ShutdownHook( StatusType Error ) {\r
+ dbg_printf("## ShutdownHook\n");\r
+ while(1);\r
+}\r
+\r
+struct LogBad_s {\r
+ uint32_t param1;\r
+ uint32_t param2;\r
+ uint32_t param3;\r
+ TaskType taskId;\r
+ OsServiceIdType serviceId;\r
+ StatusType error;\r
+};\r
+\r
+void ErrorHook( StatusType Error ) {\r
+\r
+ TaskType task;\r
+ static struct LogBad_s LogBad[ERROR_LOG_SIZE];\r
+ static uint8_t ErrorCount = 0;\r
+\r
+ GetTaskID(&task);\r
+\r
+\r
+ OsServiceIdType service = OSErrorGetServiceId();\r
+\r
+ /* Grab the arguments to the functions\r
+ * This is the standard way, see 11.2 in OSEK spec
+ */\r
+ switch(service) {\r
+ case OSServiceId_SetRelAlarm:\r
+ {\r
+ // Read the arguments to the faulty functions...\r
+ AlarmType alarm_id = OSError_SetRelAlarm_AlarmId;\r
+ TickType increment = OSError_SetRelAlarm_Increment;\r
+ TickType cycle = OSError_SetRelAlarm_Cycle;\r
+ // ... Handle this some way.\r
+ break;\r
+ }\r
+ /*\r
+ * The same pattern as above applies for all other OS functions.\r
+ * See Os.h for names and definitions.
+ */\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ dbg_printf("## ErrorHook err=%d\n",Error);\r
+\r
+ /* Log the errors in a buffer for later review */\r
+ LogBad[ErrorCount].param1 = os_error.param1;\r
+ LogBad[ErrorCount].param2 = os_error.param2;\r
+ LogBad[ErrorCount].param3 = os_error.param3;\r
+ LogBad[ErrorCount].serviceId = service;\r
+ LogBad[ErrorCount].taskId = task;\r
+ LogBad[ErrorCount].error = Error;\r
+\r
+ ErrorCount++;\r
+\r
+ // Stall if buffer is full.\r
+ while(ErrorCount >= ERROR_LOG_SIZE);\r
+}\r
+\r
+void PreTaskHook( void ) {\r
+ TaskType task;\r
+ GetTaskID(&task);\r
+// dbg_printf("## PreTaskHook, taskid=%d\n",task);\r
+}\r
+\r
+void PostTaskHook( void ) {\r
+ TaskType task;\r
+ GetTaskID(&task);\r
+// dbg_printf("## PostTaskHook, taskid=%d\n",task);\r
+}\r
+\r
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
-
-
-/*\r
- * Ramlog.h\r
- *\r
- * Created on: 2009-apr-19\r
- * Author: mahi\r
- */\r
\r
#ifndef RAMLOG_H_\r
#define RAMLOG_H_\r
-\r
+
+#include <stdint.h>\r
#include "xtoa.h"\r
-\r
+
+#if !defined(USE_RAMLOG)\r
+#define ramlog_str( _x)
+#define ramlog_dec( _x)
+#define ramlog_hex( _x)
+
+#else
+
void ramlog_puts( char *str );\r
\r
/*\r
ultoa(val,str,16);\r
ramlog_str(str);\r
}\r
+#endif
+
\r
/*\r
* var args ramlog functions\r
- */\r
+ */
+#if defined(USE_RAMLOG_PRINTF)\r
int ramlog_printf(const char *format, ...);\r
+#else
+#define ramlog_printf(format,...)
+#endif
+\r
+#endif /* RAMLOG_H_ */
\r
-#endif /* RAMLOG_H_ */\r
#ifndef TRACE_H_\r
#define TRACE_H_\r
-\r
+
+#include "simple_printf.h"\r
/**\r
*\r
* NOTE!!!!\r
#define DEBUG_LVL 2\r
#endif\r
\r
-extern int simple_printf(const char *format, ...);\r
-\r
-//#define USE_DEBUG\r
-//#define USE_TRACE\r
-\r
#define CH_ISR 0\r
#define CH_PROC 1\r
\r
--- /dev/null
+\r
+#ifndef SIMPLE_PRINTF_H_\r
+#define SIMPLE_PRINTF_H_\r
+\r
+#if defined(USE_SIMPLE_PRINTF)\r
+#define simple_printf(format,...) simple_printf(format,## __VA_ARGS__ )\r
+#else\r
+#define simple_printf(format,...)\r
+#endif\r
+\r
+#endif /* SIMPLE_PRINTF_H_ */\r
fi
fi;
-export BDIR=system/kernel/testsystem
+#export BDIR=system/kernel/testsystem
+export BDIR=examples/tiny
make BOARDDIR=et_stm32_stamp clean
make BOARDDIR=et_stm32_stamp all
if [ $? -ne 0 ]; then quit 1
HOST := $(shell uname)\r
export prefix\r
\r
+cygpath:= $(shell cygpath -m $(shell which cygpath))\r
# If we are using codesourcery and cygwin..\r
-export CYGPATH=c:/cygwin/bin/cygpath\r
+export CYGPATH=$(cygpath)\r
\r
# ---------------------------------------------------------------------------\r
# Compiler\r
# Create the target name... \r
target := $(subst /,_,$(SUBDIR))\r
\r
+#goal=$(subst /cygdrive/c/,c:/,$(abspath $@))\r
+goal=$@\r
+\r
#===== MODULE CONFIGURATION =====\r
include $(ROOTDIR)/boards/$(BOARDDIR)/build_config.mk\r
-include ../build_config.mk\r
# Compile\r
%.o: %.c\r
@echo " >> CC $<"\r
- $(Q)$(CC) -c $(CFLAGS) -o $(abspath $@) $(addprefix -I ,$(inc-y)) $(addprefix -D,$(def-y)) $(realpath $<)\r
+ $(Q)$(CC) -c $(CFLAGS) -o $(goal) $(addprefix -I ,$(inc-y)) $(addprefix -D,$(def-y)) $(realpath $<)\r
\r
# Assembler\r
\r
%.o: %.s\r
@echo " >> AS $< $(ASFLAGS)"\r
- $(Q)$(AS) $(ASFLAGS) -o $@ $<\r
+ $(Q)$(AS) $(ASFLAGS) -o $(goal) $<\r
\r
-#$(Q)$(AS) -o /cygdrive/c/apa.o $<\r
-\r
-\r
# PP Assembler \r
-.SECONDARY %.s:\r
+#.SECONDARY %.s:\r
\r
%.s: %.S\r
@echo " >> CPP $<"\r
_Bool os_arch_stack_endmark_ok( pcb_t *);
#endif
+static inline void os_arch_stack_set_endmark( pcb_t *pcb ) {
+ uint8_t *end = pcb->stack.top;
+ *end = STACK_PATTERN;
+}
+
static inline _Bool os_arch_stack_endmark_ok( pcb_t *pcb ) {
uint8_t *end = pcb->stack.top;
return ( *end == STACK_PATTERN);
* for more details.
* -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
-
#ifndef INTERNAL_H_\r
#define INTERNAL_H_\r
\r
#include <assert.h>\r
#include "Ramlog.h"\r
-\r
+#include "simple_printf.h"\r
\r
extern uint32 os_dbg_mask;\r
\r
* for more details.
* -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
-
#ifndef TASK_I_H_\r
#define TASK_I_H_\r
\r
#include <stdlib.h>\r
#include <assert.h>\r
-#include "internal.h"\r
+#include "internal.h"
+#include "Ramlog.h"\r
\r
static inline void os_pcb_print_rq( void ) {\r
pcb_t *i_pcb;\r
\r
#VPATH += $(ROOTDIR)/arch/arm/arm_cm3/kernel\r
vpath-y += $(ARCH_PATH-y)/kernel\r
-#obj-y += asm_sample.o\r
+obj-y += asm_sample.o\r
obj-y += arch_krn.o\r
\r
\r
/**\r
* Called when a task is to be run for the first time.\r
*/\r
-void os_swap_context_to(pcb_t *old_pcb, pcb_t *new_pcb ) {\r
- os_arch_swap_context_to(old_pcb,new_pcb);\r
+void os_swap_context_to(pcb_t *old_pcb, pcb_t *new_pcb ) {
+
+\r
+ os_arch_swap_context_to(old_pcb,new_pcb);\r
/* TODO: When do we return here ?? */\r
}\r
\r
WINPAGE.RESET\r
\r
WINCLEAR\r
- WINPOS 78.714 50.538 72. 24. 12. 1. W002\r
- WINTABS 13. 0. 0. 0. 0. 0. 0.\r
- ws.b.l\r
- \r
- WINPOS 146.57 50.692 89. 22. 0. 0. W005\r
- ws.Var.View %open Det_RamLog\r
- \r
- WINPOS 1.8571 50.154 83. 28. 0. 0. W001\r
- ws.area\r
- \r
- WINPOS 2.2857 0.076923 134. 62. 13. 1. W000\r
- WINTABS 10. 10. 25. 62.\r
- ws.d.l\r
+ WINPOS 0% 0% 50% 69%\r
+ d.l\r
+\r
+ WINPOS 0% 70% 50% 30%\r
+ area\r
+\r
+ WINPOS 50% 0% 50% 30%\r
+ var.ref\r
\r
+ do term\r
+\r
WINPAGE.SELECT P000 \r
\r
ENDDO\r
+\r
\r
do config save \r
do flash open\r
- data.load.elf &cfg_loadfile_g /CYGDRIVE /GNU \r
+ data.load.elf &cfg_loadfile_g c /CYGDRIVE /GNU \r
do flash close\r
print "&cfg_loadfile_g"\r
- \r
+\r
enddo\r
\r
//------------------------------------------------------------- \r
r.reset \r
do flash init\r
do flash open\r
- data.load.elf &cfg_loadfile_g /GNU \r
+ data.load.elf &cfg_loadfile_g /GNU /CYGDRIVE\r
// /CYGDRIVE\r
do flash close\r
+\r
+ GOSUB postload_&cfg_cpu_g\r
+\r
enddo\r
+\r
+postload_CortexM3:\r
+ r.s MSP 0x20005000\r
+ RETURN\r
+\r
+postload_MPC5516:\r
+postload_MPC5554:\r
+ RETURN\r
+\r
+//-------------------------------------------------------------\r
+\r
+path_fast:\r
+ y.spath.SETRECURSEDIR &cfg_project_path_g\r
+ RETURN\r
+\r
+//-------------------------------------------------------------\r
+path:\r
+ y.spath.reset\r
+ y.spath + &cfg_project_path_g/arch/arm/arm_cm3/kernel\r
+ y.spath + &cfg_project_path_g/arch/arm/arm_cm3/drivers\r
+ y.spath + &cfg_project_path_g/system/kernel\r
+ y.spath.SETRECURSEDIR &cfg_project_path_g\r
+ RETURN\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
\r
\r
\r
\r
\r
\r
+\r
+\r
\r
\r
\r
\r
\r
// Setup how to view variables and code\r
-setup.var %SYMBOL.on %HEX.on %decimal.on %index.on\r
+setup.var %SYMBOL.on %HEX.on %decimal.on %index.on %string.on\r
setup.tabsize 2.\r
\r
menu.rp autosar.men\r
\r
-//winclear\r
-winpos 0% 0% 50% 68%\r
-w.d.l\r
-winpos 50% 0% 50% 50%\r
-w.v.f /l /c\r
winpos 0% 70% 50% 30%\r
area\r
\r
area.select\r
-//area.reset\r
-//w.v.w\r
-//v.aw flags ast\r
-\r
print "## Welcome to Arc-Core simulator environment for T32 ##"\r
-print "## Select example to load from the menu Arc-Core->Load ##"\r
print ""\r
\r
\r
\r
\r
\r
+\r
+\r
\r
\r
\r
winclear my_term\r
-WinPOS 60% 0% 50% 30. 1. 1. my_term\r
+WinPOS 50% 50% 50% 50% 1. 1. my_term\r
term.size 80. 300.\r
term.scroll on\r
term.mode ASCII\r
\r
\r
\r
+\r