After I fixed all the issues I had at the beginning with ChibiOS, I have a question related to the stack and heap.
First, you should notice that I am new to this stuff and just have basic knowledge about things like heap grows upwards, stack downwards etc. etc.
I took the FATFS example for the STM32F103 and ported it to my own board. I can run the test benchmark over the shell etc. I didn't change anything, there's just running the blinker thread, the shell and the fatfs itself. After doing BYTE buffer[4096] in a function which should write to a file on the SD card, the chip run into an unhandled expection whenever I called that function which uses that buffer afterwards with strcpy (the mcu dosen't crash when I call the function I wrote myself, it crashes at the strcpy() call inside that function). After some register viewing, I found out that the stack pointer has the value: 0x20000400 which might be the bottom of the stack.
So, here's my question: I have a STM32F103VET on my board, that thing does have 64kB of SDRAM. Does ChibiOS use so much memory, that I cannot get even 4k of stack in a program, which does nothing beside blinking an LED, running the shell and FATFS?
As I said, I am pretty new to the whole field of embedded stuff. Could it be, that I am doing something horribly wrong, or that I have to set stack limits etc. in ChibiOS?
I could only find the debug and check triggers in chconfig.h.
This is my function:
Code: Select all
static void cmd_write(BaseSequentialStream *chp) {
FRESULT ferr;
FIL fdst;
UINT written;
BYTE buffer[64];
ferr = f_open(&fdst, "0:log.txt", FA_CREATE_ALWAYS | FA_WRITE | FA_READ);
if(ferr != FR_OK) {
chprintf(chp, "f_open() failed!\r\n");
return;
}
strcpy(buffer, "Hello World!");
f_write(&fdst, buffer, sizeof(buffer), &written);
f_close(&fdst);
return;
}
This works that way, but when I do BYTE buffer[4096], it crashes at the strcpy().
What can you tell me to this?
I use this toolchain: https://launchpad.net/gcc-arm-embedded
~ Tectu