arm - FreeRTOS stack corruption on STM32F4 with gcc -
arm - FreeRTOS stack corruption on STM32F4 with gcc -
i'm trying freertos running on stm32f4discovery board. have installed summon-arm-toolchain , created makefile compile code. here makefile:
toolchain_path:=/usr/local/sat/bin toolchain_prefix:=arm-none-eabi optlvl:=0 freertos:=.. startup:=$(curdir)/startup linker_script:=$(freertos)/utilities/stm32_flash.ld include=-i$(curdir) # setting other include path... build_dir = $(curdir)/build bin_dir = $(curdir)/binary vpath %.c $(curdir) # setting other vpath... vpath %.s $(startup) asrc=startup_stm32f4xx.s # project source files src+=stm32f4xx_it.c src+=system_stm32f4xx.c src+=main.c # freertos source files src+=port.c src+=list.c src+=queue.c src+=tasks.c src+=timers.c src+=heap_2.c src+=syscalls.c src+=stm32f4xx_usart.c # other peripheral source files... cdefs=-duse_stdperiph_driver cdefs+=-dstm32f4xx cdefs+=-dhse_value=8000000 mcuflags=-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp commonflags=-o$(optlvl) -g -wall cflags=$(commonflags) $(mcuflags) $(include) $(cdefs) ldlibs= ldflags=$(commonflags) -fno-exceptions -ffunction-sections -fdata-sections -nostartfiles -wl,--gc-sections,-t$(linker_script) obj = $(src:%.c=$(build_dir)/%.o) cc=$(toolchain_path)/$(toolchain_prefix)-gcc ld=$(toolchain_path)/$(toolchain_prefix)-gcc objcopy=$(toolchain_path)/$(toolchain_prefix)-objcopy as=$(toolchain_path)/$(toolchain_prefix)-as ar=$(toolchain_path)/$(toolchain_prefix)-ar gdb=$(toolchain_path)/$(toolchain_prefix)-gdb $(build_dir)/%.o: %.c $(cc) $(cflags) $< -c -o $@ all: $(obj) $(as) -o $(asrc:%.s=$(build_dir)/%.o) $(startup)/$(asrc) $(cc) -o $(bin_dir)/$(target).elf $(ldflags) $(obj) $(asrc:%.s=$(build_dir)/%.o) $(ldlibs) $(objcopy) -o ihex $(bin_dir)/$(target).elf $(bin_dir)/$(target).hex $(objcopy) -o binary $(bin_dir)/$(target).elf $(bin_dir)/$(target).bin
i modified project in folder cortex_m4f_stm32f407zg-sk of freertos demo projects(removing existing tasks , creating own). here main function:
int main(void) { int ret; prvsetuphardware(); debugprintf("freertos v7.3.0 starting\n"); ret = xtaskcreate(sampletask0, (signed char *) "t0", configminimal_stack_size, null, 2, null); if (ret == pdtrue) { debugprintf("task %x creared successfully:%d.\n", sampletask0, ret); } else { debugprintf("task 0 created failed.\n"); } ret = xtaskcreate(sampletask1, (signed char *) "t1", configminimal_stack_size, null, 1, null); if (ret == pdtrue) { debugprintf("task %x creared successfully:%d.\n", sampletask1, ret); } else { debugprintf("task 1 created failed.\n"); } debugprintf("starting scheduler...\n"); vtaskstartscheduler(); (;;); }
i have configured configminimal_stack_size 4096 in freertosconfig.h , code goes task scheduler started , invoked sampletask0 function. here task code:
void sampletask0(void *pvparameters) { (void) pvparameters; uint16_t delay; (;;) { delay = 10000; debugprintf("task 0 running\n"); while(delay) {delay--;} } vtaskdelete(null); }
the task 1 function same task 0 except prints different information. these code compile , after write binary board, sampletask0 not work expected. debugprintf function sends character through usart3 prints "tas" , halts. traced code gdb , execute code step, "task 0 running" got printed when returned task function(before "while(delay) {delay--;}") error occurred:
cannot access memory @ address 0xa5a5a5a5
sampletask0 (pvparameters=0x0) @ main.c...
according freertos documents, stack of each task filled 0xa5 bytes upon creation. think there may wrong stack. have set configcheck_for_stack_overflow 2 enable stack overflow detection, hook function had not been invoked when happened.
the startup_stm32f4xx.s in cortex_m4f_stm32f407zg-sk created ewarm toolchain , replaced startup file in stm32f4-discovery_fw_v1.1.0 downloaded st website. potentially corrupt stack, i'm not sure this. have ideas this?
archive of thread on top here: additional info since lastly archive snapshot can found on live freertos back upwards forum. http://www.freertos.org/freertos_support_forum_archive/february_2013/freertos_freertos_stack_corruption_on_stm32f4_with_gcc_6772412.html
gcc arm freertos stack-corruption stm32f4discovery
Comments
Post a Comment