FreeRTOS debug

Go To Last Post
20 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
I am working on a simple project with a 328P microcontroller where I use FreeRTOS.

To debug, I use a serialport that does not really give me much.

My question is what debug options I have on a 328P if I would like it in more detail. I have found something called "Tracealyzer", as an extension for the avr studio, which provides what I want, but which i think, can not be used for that microcontroller?

What are the debug options for FreeRTOS on a AtMega 328 microcontroller?

 

Ty

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need to get a debugWire interface to connect between PC+Studio and the 328P. Potential devices are Atmel-ICE, Snap! and (I believe) PickKit4.

 

Of those Snap: https://www.microchip.com/develo... is the "cheap" option.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Or an ATmega328P Xplained Mini: https://www.microchip.com/developmenttools/ProductDetails/PartNO/ATMEGA328P-XMINI

 

it has a built-in debugger - although significantly slower than a proper Atmel-ICE.

 

Dunno how Snap compares on speed?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So I will actually be able to use "Tracealyzer" for the 328P?

 

I have a dragon available, can I use that?

 

Sorry, but I'm pretty inexperienced

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What kind of "debug" are you looking for?

 

Just the general chip-level stuff as found in the standard Atmel Microchip Studio - or something that's specifically "FreeRTOS-aware" ?

 

For the latter, you might be better asking on the FreeRTOS forums ...

 

a simple project with a 328P

so does it really need an RTOS at all ?

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

On this page:

 

https://percepio.com/tracealyzer/

 

it says:

No special trace hardware is required, as Tracealyzer relies on efficient software instrumentation with minimal overhead. This way, it works on essentially any processor or microcontroller, assuming you have a few kilobytes available for the trace recorder module. It is designed for 32-bit target processors and upwards, including ARM Cortex-M MCUs such as STMicroelectronics STM32, NXP LPC and Kinetis series, Renesas Synergy, Silicon labs EFM32, Cypress PSoC, Atmel SAM, TI MSP432, TI TMC4 and Infineon XMC4. We also support Renesas RX, Renesas RZ, Microchip PIC32, Atmel AVR32, ARM Cortex-R, ARM Cortex-A, Xilinx Zynq, Xilinx Microblaze, Altera Nios II and Synopsys ARC processors. And even if your processor family is not yet directly supported, you can easily develop your own port. You just need to define a few macros, mainly for reading the current time.

So I don't think it's going to work for 328P because (a) it doesn't have "kilobytes" for trace storage and (b) it is 8bit not 32bit. But to be sure I would contact and check with Percepio.

 

BTW I gotta ask - what benefit do you see in putting an RTOS in a micro that only has 32K (and 2K RAM) in the first place? Systems don't usually get so complex that an RTOS is required until pu around the 64K+ mark usually.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
what benefit do you see in putting an RTOS in a micro that only has 32K (and 2K RAM) in the first place? 

Indeed.

 

Especially as it's only a "simple" project anyhow!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Tracealyzer" provides a visual image of tasks and resource consumption.

 

https://percepio.com/wp-content/...

 

Its something like that, I try to achieve

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Easyanton wrote:
Its something like that, I try to achieve
Then I'd consider doing the design with an ARM not an AVR. Percepio have "Atmel SAM" in their list of supported targets.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Easyanton wrote:
To debug, I use a serialport that does not really give me much.

What it gives, surely, is down to you - not a limitation of the serial port as such?

 

 

As clawson pointed out from the Tracealyser blurb, it's going to take some resources to do that - more than is available on a mere 328P.

 

Again, is anything on a 328P going to be that complicated ... ?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. May 19, 2021 - 08:43 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why is my project important?

 

I'm trying to learn something about FreeRTOS and had a 328p. I want to get as far with it as possible, even if you think it's a small processor.

 

I agree that I can not use "Tracealyzer", but in the first answers, I got the impression that I could.

 

But my question was what options or alternatives I have?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Easyanton wrote:
I'm trying to learn something about FreeRTOS

A small 8-bit processor really isn't a great place to do that.

 

As you're already finding, you will be constantly struggling against the limitations of the platform - rather than actually learning stuff about FreeRTOS.

 

You'd be far better off on a more common platform - not least because you will then have a far bigger & better pool of resources and experience to call upon.

 

There is a Windows-based simulator: https://www.freertos.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html - that might be the best option for learning about FreeRTOS - without having to get bogged-down in details of target hardware ...

 

Easyanton wrote:
my question was what options or alternatives I have?

I think #2 & #3 answered that ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. May 19, 2021 - 08:58 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Easyanton wrote:
Sorry, but I'm pretty inexperienced

No need to apologise for that - we all need to start somewhere.

 

But it's generally better to start with the basics before moving on to more advanced stuff - like an RTOS.

 

Some microcontroller "getting started" tips: https://www.avrfreaks.net/commen...

 

For getting familiar with Atmel Microchip Studio - including its debug facilities - see: https://www.avrfreaks.net/commen...

 

 

https://www.microchip.com/en-us/development-tools-tools-and-software/microchip-studio-for-avr-and-sam-devices

 

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the past I have noodled about with FreeRTOS on a 328P (I basically determined that something like 5 tasks is the limit because of the limited RAM) but I did most of the experimenting/learning in the Studio simulator without restoring to real hardware but this does rely on doing tasks that are not dependent on any kind of "external stimulus" (which is not typical of an average microcontroller app!)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Easyanton wrote:
My question is what debug options I have on a 328P if I would like it in more detail.
assertions and exceptions

Easyanton wrote:
I have found something called "Tracealyzer", as an extension for the avr studio, which provides what I want, but which i think, can not be used for that microcontroller?
Can as Tracealyzer has a stream option; unfortunately, mega328P has only one USART whereas mega328PB has two USART.

Easyanton wrote:
What are the debug options for FreeRTOS on a AtMega 328 microcontroller?
FreeRTOS's assert

 


by Jack Ganssle :

Using Asserts in Embedded Systems | Interrupt (Memfault)

 

Tracealyzer for FreeRTOS - Percepio AB

[near bottom]

We provide predefined stream ports for [SEGGER J-Link, Arm ITM, Arm SWO, USB CDC, TCP/IP]

and it is quite straight-forward to define your own stream port, e.g. to stream to a memory card or any other available interface. The data rates resulting from an RTOS trace are typically 20-200 KB/s.

...

USART | AT15007: Differences between ATmega328/P and ATmega328PB

 

FreeRTOS - The Free RTOS configuration constants and configuration options - FREE Open Source RTOS for small real time embedded systems

[near bottom]

configASSERT

...

due to Interrupt | A community and blog for embedded software makers (Memfault) (at Search, enter FreeRTOS)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Easyanton wrote:
I have a dragon available, can I use that?
Yes

Atmel megaAVR/tinyAVR OCD (debugWIRE) | AVR Dragon

 

P.S.

debugWIRE via USB UART | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
BTW I gotta ask - what benefit do you see in putting an RTOS in a micro that only has 32K (and 2K RAM) in the first place?
AVRxt's additional RAM eases.

clawson wrote:
Systems don't usually get so complex that an RTOS is required until pu around the 64K+ mark usually.
Otherwise, event processing is an alternative to RTOS; AVRxt adds hardware events and a prioritized interrupt controller.

A scheduler is sometimes enough.

 


Getting Started with FreeRTOS on megaAVR® 0-series

FreeRTOS™ Using Percepio® Trace on ATmega4809

 

Modern Embedded Programming: Beyond the RTOS « State Space (events, hierarchical state machines, more : Key concept: reactive systems | Quantum Leaps)

EVSYS - Event System | Migration from the megaAVR® to AVR® Dx Microcontroller Families

Interrupts | Migration from the megaAVR® to AVR® Dx Microcontroller Families

OctOS: a simple tasking system for AVRs | AVR Freaks

more : [TUT][SOFT] RTOS for AVR | AVR Freaks

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
Again, is anything on a 328P going to be that complicated ... ?
Yes

ka7ehk has some topics of interest on such.

https://www.avrfreaks.net/search/site/mega328?solrsort=ds_created%20desc&filter_by=9631&f%5B0%5D=is_uid%3A7050

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A dragon will work fine with AS7 and can debug/single step/run to cursor/breakpoints/etc...   practice a few times getting into and out of debugWire mode, before any serious debug sessions.

Dwire does require cycling power on the chip to toggle into the mode, so make sure you can do that easily.  

Another alternative to the dragon, as already mentioned is the explained board above. cheap, has built in debugger, and is also Arduino shield compatible as well, so you can use just about any shield made for the UNO.

Once you get a taste of RTOS, you will want to move to a larger micro, where you have more room to grow.

Forgot to add, a logic analyzer is a must have debug tool, the Saleae units are good, but you can find cheap Chinese cloans that will work with the Saleae software (windows) or similar programs for Linux if needed.

 

Jim

 

 

Keys to wealth:

Invest for cash flow, not capital gains!

Wealth is attracted, not chased! 

Income is proportional to how many you serve!

 

Last Edited: Wed. May 19, 2021 - 06:11 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


ki0bk wrote:
A dragon will work fine with AS7 and can debug/...
AVR Dragon disadvantages :

  • EOL therefore not in MPLAB X
  • not EDBG

Conversely, AVR Dragon can be hardened and AVR Dragon is in AVaRICE.

ki0bk wrote:
Once you get a taste of RTOS, ...
... one may not want another taste (deadlock, livelock, starvation, priority inversion, <many>)

Try to obtain RTOS that are OSS or FOSS; for AVR, consider the RTOS's license.

Apply concurrency rules and recommendations.

Consider a framework (events)

ki0bk wrote:
... a logic analyzer is a must have debug tool, ...
Concur

 


AVR Dragon (Microchip Technology)

Microchip Packs Repository (bottom for tool packs)

Dragon (2/3 page for DragonLair)

AVR Devices | Choosing a Debug Method – VisualGDB Documentation

 

Beyond the RTOS: A Better Way to Design Real-Time Embedded Software « State Space

[1/4 page]

 

SEI CERT C Coding Standard - SEI CERT C Coding Standard - Confluence

 

Troubleshooting real-time software issues using a logic analyzer - Embedded.com

Logic analyzers | Supported hardware - sigrok

24Msps, USB high-speed, 30USD :

1BitSquared - BitMagic Basic Logic Analyzer due to Tigard Bitmagic Logic Analyzer - Crowd Supply | Mouser

USB super-speed :

 

"Dare to be naïve." - Buckminster Fuller