❌

Normal view

There are new articles available, click to refresh the page.
Today β€” 4 July 2025Main stream

Learning Baremetal Programming in Cortex M4 (STM32 F4) - 1

17 September 2024 at 00:00

I am following this Baremetal Programming Series (Low Byte Productions Channel), inorder to learn about ARM microcontrollers, writing drivers (I've a goal to write a driver for a Serial Communication Protocol maybe CAN or Q-SPI, etc.) and learning some C constructs as well which I will then emulate in Renode.

Some notes,

  • MACROS{.verbatim} are instructions that asks the C preprocessor to do text replacements.

  • Behind the Scenes of libopencm3{.verbatim}

    • The memory mapped address of a pin is calculated in the pre-processing stage itself using macros.
  • SYS_TICK{.verbatim} is like a Wall Clock.

  • weak functions{.verbatim} are functions whose implementation can be redefined.

For Renode implementation, I just loaded the ELF of program used in the episode as like for the Hello World, Intro to Renode from Interrupt and I did used the same Makefiles and Linker scripts once again. (Those 2 seems to be a huge mess ? Is it ?)

I shouldn't be lazy enough to tinker them in future.

Then Looked the state of Pin A5 (External LED) and I could see that the state toggles. I think I could even log the data or check this working using Robot Framework.

Next, I need to look at Renode docs to discover more functionalities and then continue with Episode 3 on PWM and Timers!

TIL (22/12/2023)

22 December 2023 at 00:00

I was thinking about what I can do next with ESP32 and micro-ROS and so I thought to learn RTOS first as it is also used and then dwelve into microROS.

For learning RTOS(gonna a start with FreeRTOS itself), I came across this tutorial which looks good.

Then I learned about Policy Gradient methods to solve MDPs from Deep RL course I’m doing from HF. Really the math is little involved which I have to dwelve step by step. While going across Policy Gradient Theorem derivation, I came across few tricks and assumptions used, for e.g.

  • Reinforce Trick: \(\frac{\nabla_{\theta}P(\tau)}{P(\tau)} = \nabla_{\theta}\\log(P(\tau))\)

  • State Distribution is independent of parameters($\theta$) of policy (I think this implies that the choice of action from action distribution given by the policy isn’t covered by the policy i.e its not a part of policy I guess).

  • Sampling m trajectories from the trajectory($\tau$) distribution

Next I have too do the hands-on and refer more about it.

RTOS

  • We can use RTOS when we have to run many tasks concurrently or if it’s time demanding, which can’t be done in general Super loop configurations(I mean the usual setup and loop parts).

  • ESP32 uses a modified version of FreeRTOS which supports its SMP (Symmetric MultiProcessing) architecture to schedule tasks by using both cores! (but this tutorials is only for multi-tasking in single core)

Task Scheduling

  • Context Switching : How are tasks are switched from one to another.

  • Task pre-emption

❌
❌