Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event logging in Embedded Systems

Normally, in SBC running RTOS, it would be an easy task to write data/event logs onto an external media such as SD cards. However, in embedded systems that uses microcontroller, e.g. PIC microchips, have limited data/program memory. Although some chipset have the support for external media, assumming that it doesn't, how would one log in MCU?

The only plausible way that I could think of is to write it to MCU's EEPROM, but is this feasible? If this could be done, how would one write and read?

like image 303
freonix Avatar asked Aug 11 '11 06:08

freonix


3 Answers

Logging can be performed to any memory device, SD cards included (assuming the relevant hardware peripheral is available). If there is an external device attached over a serial port, you can write data to it.

Commonly, event logging is done in exceptional cases only. Writing to EEPROM or Flash (for newer devices) is relatively slow, consumes power, and uses up a finite resource (space, and erase cycles).

For debugging, using a serial port (or the SWO port on Cortex-M3) is common.

like image 91
Yann Ramin Avatar answered Oct 23 '22 23:10

Yann Ramin


You can implement a logging facility which simply writes a byte into an array each time you want to log an event. The log list can then be retrieved and converted to a human readable list of events. This approach has the benefit to be less intrusive for real-time applications.

I used this approach for an application where 100-200 events were generated in a 1-2 minute test session. The list was then downloaded over a serial port and analyzed with a little Python script.

like image 29
lorcap Avatar answered Oct 23 '22 21:10

lorcap


Depending on your data needs, you could either go for a SPI flash or an I²C EEPROM.

I2C EEPROMS are smaller in terms of storage but its interface is available in most microcontrollers (if not, it is relatively easy to do it in software with regular IO pins) and they are a lot slower (mainly because of the I2C bus that is limited at 1Mhz). It is easy to find them up to 1mbit in capacity and with 8DIP packaging.

SPI flashes are faster, with higher density and often cheaper, so if you need fast writes and, to be honest, better technology you should go for them.

like image 1
Vinicius Kamakura Avatar answered Oct 23 '22 21:10

Vinicius Kamakura