Heat a large skillet or frying pan over medium heat.
Add the diced bacon to the pan and cook until it becomes crispy and releases its fat.
Add the chopped onion and minced garlic to the pan with the bacon. Sauté until the onion becomes translucent and lightly browned.
If using, add the butter or oil to the pan and allow it to melt and mix with the bacon fat.
Gradually add the cassava flour to the pan, stirring continuously. Toast the flour for about 5-7 minutes or until it becomes golden brown. Be sure to keep stirring to avoid burning.
Season with salt and pepper to taste. Feel free to adjust the seasoning according to your preference.
Remove the pan from the heat and let the farofa cool slightly before serving.
Serve the farofa as a side dish with your favorite Brazilian meals or sprinkle it on top of dishes like feijoada or barbecue.