<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by bhuvaneshwari kanagaraj on Medium]]></title>
        <description><![CDATA[Stories by bhuvaneshwari kanagaraj on Medium]]></description>
        <link>https://medium.com/@bhuvaneshwarii026?source=rss-66e2c8838299------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ib30j23JbjhSSow1u5mbxA.jpeg</url>
            <title>Stories by bhuvaneshwari kanagaraj on Medium</title>
            <link>https://medium.com/@bhuvaneshwarii026?source=rss-66e2c8838299------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 21:49:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bhuvaneshwarii026/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Breaking Bad Habits: Using the 4 Laws of Behavior Change]]></title>
            <link>https://medium.com/@bhuvaneshwarii026/breaking-bad-habits-using-the-4-laws-of-behavior-change-c2db1130e722?source=rss-66e2c8838299------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2db1130e722</guid>
            <category><![CDATA[atomic-habits-james-clear]]></category>
            <category><![CDATA[bad-habits]]></category>
            <category><![CDATA[atomic-habits-summary]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[leanring-journeys]]></category>
            <dc:creator><![CDATA[bhuvaneshwari kanagaraj]]></dc:creator>
            <pubDate>Wed, 29 Jan 2025 12:32:35 GMT</pubDate>
            <atom:updated>2025-01-29T12:32:35.325Z</atom:updated>
            <content:encoded><![CDATA[<p>We all have habits we’d like to break — whether it’s scrolling mindlessly on social media, procrastinating, or reaching for unhealthy snacks. The problem isn’t that we lack willpower; it’s that we don’t have the right strategy. In <em>Atomic Habits</em>, James Clear introduces the <strong>4 Laws of Behavior Change</strong>, a framework for breaking bad habits and replacing them with better ones. Here’s how I’ve used these laws to overcome my own bad habits and how you can too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*P9AAahS9r1Kj7cMg.jpg" /></figure><h3>1. Make It Invisible (Remove the Cue)</h3><p>Every habit starts with a cue — a trigger that prompts the behavior. To break a bad habit, the first step is to make the cue invisible.</p><p><strong>Example from My Life:</strong><br>I used to spend hours scrolling through social media every evening. The cue? My phone sitting right next to me on the couch. To make the cue invisible, I started charging my phone in another room at night. Out of sight, out of mind.</p><p><strong>Actionable Tip:</strong><br>Identify the cue for your bad habit and remove it. For example:</p><ul><li>If you snack on junk food while watching TV, stop keeping snacks in the house.</li><li>If you check your phone first thing in the morning, leave it in another room overnight.</li></ul><h3>2. Make It Unattractive (Reframe the Craving)</h3><p>Habits are driven by cravings — the anticipation of a reward. To break a bad habit, you need to make it unattractive by reframing how you think about it.</p><p><strong>Example from My Life:</strong><br>I used to crave sugary drinks because I associated them with energy and comfort. To make this habit unattractive, I started focusing on the negative consequences — like the sugar crash and the long-term health risks. I replaced my craving with a healthier alternative: Fruit Juice!</p><p><strong>Actionable Tip:</strong><br>Reframe your mindset by focusing on the downsides of the habit. Ask yourself:</p><ul><li>How does this habit harm me in the long run?</li><li>What am I sacrificing by continuing this habit?</li></ul><h3>3. Make It Difficult (Increase Friction)</h3><p>The harder it is to perform a habit, the less likely you are to do it. By increasing friction, you can make bad habits more difficult to execute.</p><p><strong>Example from My Life:</strong><br>I used to waste hours Netflix. To make this habit harder, I removed streaming apps from my smart TV and logged out of my accounts. Now, if I want to watch something, I have to go through the hassle of logging back in. Most of the time, I decide it’s not worth the effort.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*IMk9pCbTHmm8KpeP.gif" /><figcaption>Ha Ha</figcaption></figure><p><strong>Actionable Tip:</strong><br>Add obstacles to your bad habits. For example:</p><ul><li>If you want to reduce screen time, set up app blockers or time limits on your devices.</li><li>If you want to stop impulse shopping, unsubscribe from promotional emails and remove saved payment methods.</li></ul><h3>4. Make It Unsatisfying (Add a Consequence)</h3><p>We’re more likely to repeat habits that are immediately satisfying. To break a bad habit, you need to make it unsatisfying by adding a consequence.</p><p><strong>Example from My Life:</strong><br>I used to procrastinate on important tasks by telling myself, “I’ll do it later.” To make this habit unsatisfying, I started using a habit tracker and marked a red “X” for every day I procrastinated. Seeing a streak of red X’s was a visual reminder of my failure, which motivated me to take action.</p><p><strong>Actionable Tip:</strong><br>Add accountability or consequences to your bad habits. For example:</p><ul><li>Tell a friend about your goal and ask them to check in with you regularly.</li><li>Use a habit tracker to monitor your progress and hold yourself accountable.</li></ul><h3>Bonus: Replace the Bad Habit with a Good One</h3><p>Breaking a bad habit is easier when you replace it with a better alternative. James Clear calls this “habit substitution.”</p><p><strong>Example from My Life:</strong><br>When I felt the urge to scroll through social media, I replaced it with a healthier habit: reading a book or listening to a podcast. Over time, the new habit became automatic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*Kh9VN9u6AoiKMMJe.gif" /></figure><p><strong>Actionable Tip:</strong><br>Identify the underlying need your bad habit fulfills and find a healthier way to meet that need. For example:</p><ul><li>If you snack out of boredom, try drinking herbal tea or going for a walk instead.</li><li>If you procrastinate because a task feels overwhelming, break it into smaller, manageable steps.</li></ul><h3>Conclusion: Small Changes, Big Results</h3><p>Breaking bad habits isn’t about willpower — it’s about strategy. By making your bad habits invisible, unattractive, difficult, and unsatisfying, you can create an environment that supports positive change. Remember, progress takes time, so be patient with yourself. Start small, stay consistent, and celebrate every step forward.</p><p>What’s one bad habit you’d like to break? Share it in the comments, and let’s support each other on this journey!</p><p>This blog is designed to be practical, relatable, and actionable, with real-life examples and tips that readers can apply immediately. Let me know if you’d like to adjust anything!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2db1130e722" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build a Morning Routine That Sticks: Lessons from Atomic Habits]]></title>
            <link>https://medium.com/@bhuvaneshwarii026/how-to-build-a-morning-routine-that-sticks-lessons-from-atomic-habits-2edb1c82b3df?source=rss-66e2c8838299------2</link>
            <guid isPermaLink="false">https://medium.com/p/2edb1c82b3df</guid>
            <category><![CDATA[life]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[atomic-habits-summary]]></category>
            <category><![CDATA[atomic-habit]]></category>
            <category><![CDATA[morning-routines]]></category>
            <dc:creator><![CDATA[bhuvaneshwari kanagaraj]]></dc:creator>
            <pubDate>Tue, 28 Jan 2025 12:32:00 GMT</pubDate>
            <atom:updated>2025-01-28T12:32:00.056Z</atom:updated>
            <content:encoded><![CDATA[<p>Mornings are the foundation of our day. How we start our morning often determines how the rest of the day unfolds. Yet, building a morning routine that sticks can feel like an impossible task. I’ve tried and failed countless times — waking up early only to hit snooze, planning elaborate routines only to abandon them after a few days. That was until I discovered <em>Atomic Habits</em> by James Clear. This book taught me that the secret to building a lasting morning routine isn’t about willpower; it’s about systems, simplicity, and consistency. Here’s how I’ve applied the principles of <em>Atomic Habits</em> to create a morning routine that actually sticks.</p><h3>1. Start Small: The Power of Tiny Habits</h3><p>One of the biggest mistakes I made was trying to overhaul my entire morning at once. I’d set ambitious goals like meditating for 20 minutes, journaling, exercising, and reading — all before 7 a.m. Unsurprisingly, I’d burn out within days.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2uiVue4mQBRRpf-D.jpg" /></figure><p>James Clear emphasizes the importance of starting small. Instead of trying to do everything at once, I began with just one habit: drinking a glass of water as soon as I woke up. It was so simple that I couldn’t fail. Over time, I added more habits, like stretching for 2 minutes or writing down one thing I was grateful for.</p><p><strong>Actionable Tip:</strong><br>Choose one tiny habit to start your morning. It could be as simple as making your bed or taking three deep breaths. The key is to make it so easy that you can’t say no.</p><h3>2. Design Your Environment for Success</h3><p>Your environment plays a huge role in shaping your habits. If your phone is the first thing you reach for in the morning, you’re likely to fall into the trap of scrolling through social media. To build a better morning routine, I redesigned my environment to make good habits easier and bad habits harder.</p><p>For example:</p><ul><li>I placed my water bottle on my nightstand so it’s the first thing I see when I wake up.</li><li>I started charging my phone in another room to avoid the temptation of checking it first thing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/0*ZPfH3V_giIR3or7K" /></figure><p><strong>Actionable Tip:</strong><br>Think about the cues in your environment that trigger bad habits. How can you remove or replace them? Set up your space to support the habits you want to build.</p><h3>3. Stack Your Habits</h3><p>Habit stacking is one of the most powerful strategies of <em>Atomic Habits</em>. <strong><em>The idea is to pair a new habit with an existing one. For example, if you already brush your teeth every morning, you can stack a new habit like doing 5 minutes of stretching right after.</em></strong></p><p>Here’s how I’ve used habit stacking in my morning routine:</p><ul><li>After I drink water, I do 2 minutes of deep breathing.</li><li>After I make my bed, I write down one thing I’m grateful for.</li><li>After I shower at night, I spend 5 minutes journaling.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q343CdbmgVCKM0KV" /></figure><p><strong>Actionable Tip:</strong><br>Identify a habit you already do consistently in the morning and stack a new habit onto it. Start small and build from there.</p><h3>4. Track Your Progress</h3><p>What gets measured gets managed. Tracking your habits is a simple yet effective way to stay consistent. I started using a habit tracker to mark off each day I completed my morning routine. There’s something incredibly satisfying about seeing a streak of successful days — it motivates me to keep going.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*S9IzmL9OW5F50tfC.png" /><figcaption>Use Google Calender for Tracking</figcaption></figure><p><strong>Actionable Tip:</strong><br>Use a habit tracker (an app, a journal, or even a simple calendar) to monitor your progress. Celebrate small wins to stay motivated.</p><h3>5. Focus on Identity, Not Outcomes</h3><p>One of the most profound lessons from <em>Atomic Habits</em> is the idea of identity-based habits. Instead of focusing on what you want to achieve, focus on who you want to become. For example, instead of saying, “I want to wake up early,” tell yourself, “I am a morning person.”</p><p>This shift in mindset has been transformative for me. I no longer see my morning routine as a chore but as an opportunity to become the best version of myself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/201/0*03kdRw17mavYJX-Y" /><figcaption>Jamesclear.com</figcaption></figure><p><strong>Actionable Tip:</strong><br>Ask yourself, “Who do I want to be?” Then, build habits that align with that identity. For example, if you want to be a healthy person, start with a 5-minute morning workout.</p><h3>Conclusion: Small Steps, Big Results</h3><p>Building a morning routine that sticks isn’t about perfection — it’s about progress. By starting small, designing your environment, stacking habits, tracking your progress, and focusing on your identity, you can create a routine that transforms your mornings and, ultimately, your life.</p><p>Remember, it’s not about doing everything at once. It’s about showing up consistently, one tiny habit at a time.</p><blockquote>As James Clear says, “You do not rise to the level of your goals. You fall to the level of your systems.” So, start small, stay consistent, and watch how your mornings — and your life — begin to change.</blockquote><p>What’s one tiny habit you can start tomorrow morning? Let me know in the comments!</p><p>This blog is designed to be relatable, actionable, and inspiring, with practical tips that readers can implement immediately. Let me know if you’d like to tweak anything!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2edb1c82b3df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Atomic Habits is Transforming My Life]]></title>
            <link>https://medium.com/@bhuvaneshwarii026/how-atomic-habits-is-transforming-my-life-d3f9d79075d6?source=rss-66e2c8838299------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3f9d79075d6</guid>
            <dc:creator><![CDATA[bhuvaneshwari kanagaraj]]></dc:creator>
            <pubDate>Mon, 27 Jan 2025 10:32:04 GMT</pubDate>
            <atom:updated>2025-01-27T10:32:04.452Z</atom:updated>
            <content:encoded><![CDATA[<p>In a world filled with distractions, procrastination, and the constant pressure to achieve more, it’s easy to feel overwhelmed. I’ve always struggled with consistency — starting new habits only to abandon them a few days later, or setting big goals without a clear plan to achieve them. That was until I stumbled upon <em>Atomic Habits</em> by James Clear. This book has been a game-changer for me, and I want to share how it’s helping me reshape my life, one small habit at a time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*-aus_XeC9t8ruKqH" /><figcaption>Huu Yah!</figcaption></figure><h3>What Are Atomic Habits?</h3><p>The core idea of <em>Atomic Habits</em> is simple yet profound: small, incremental changes compound over time to create remarkable results. James Clear argues that it’s not about making massive, sweeping changes overnight but rather focusing on tiny, consistent improvements. These “atomic” habits, when repeated consistently, lead to transformative outcomes.</p><h3>The Power of 1% Improvements</h3><p>One of the most impactful concepts from the book is the idea of getting 1% better every day. At first, it doesn’t seem like much — how much can 1% really matter? But as Clear explains, small improvements compound over time. If you can improve by just 1% every day, you’ll be 37 times better by the end of the year. This mindset shift has helped me focus on progress, not perfection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*o38yCnRudciWOFDM.jpg" /></figure><p>For example, instead of trying to read 50 pages of a book in one sitting (and failing), I started with just one page a day. Over time, this small habit grew, and now I’m reading more than ever without feeling overwhelmed.</p><h3>The Habit Loop: Cue, Craving, Response, Reward</h3><p>Another key takeaway from the book is the concept of the habit loop. Clear breaks down habits into four stages: cue, craving, response, and reward. Understanding this cycle has helped me identify and change my habits more effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iYG7gHAGhq1NtdVF" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/0*75N3uvVH07HLoJPl" /></figure><p>For instance, I used to mindlessly scroll through social media every time I felt bored (cue). Now, I’ve replaced that habit with something more productive, like journaling or doing a quick workout. By recognizing the cue and consciously choosing a better response, I’ve been able to break free from unproductive habits.</p><h3>Identity-Based Habits</h3><p>One of the most profound ideas in <em>Atomic Habits</em> is the concept of identity-based habits. Instead of focusing solely on outcomes (e.g., “I want to lose weight”), Clear suggests focusing on who you want to become (e.g., “I want to be a healthy person”). This shift in mindset has been transformative for me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TPCAIF363uA32Ys3.png" /></figure><p>For example, instead of saying, “I want to write a book,” I now tell myself, “I am a writer.” This small change in identity has made it easier to adopt habits that align with that identity, like writing for 15 minutes every day. It’s no longer about achieving a specific goal but about becoming the person I want to be.</p><h3>The Role of Environment</h3><p>Clear emphasizes the importance of designing your environment to support your habits. I’ve started applying this by making small changes to my surroundings. For instance, I placed a water bottle on my desk to remind myself to stay hydrated and left my workout clothes by my bed to make it easier to exercise in the morning. These tiny tweaks have made a big difference in helping me stick to my habits.</p><h3>Tracking and Reflection</h3><p>Another practice that has helped me is habit tracking. Clear suggests keeping a simple tracker to monitor your progress. I’ve started using a habit tracker app, and there’s something incredibly satisfying about marking off each day I complete a habit. It keeps me motivated and accountable.</p><p>Additionally, I’ve incorporated regular reflection into my routine. Every Sunday, I take a few minutes to review my week, celebrate my wins, and identify areas for improvement. This practice has helped me stay mindful and intentional about my habits.</p><h3>The Ripple Effect of Atomic Habits</h3><p>What’s truly amazing about <em>Atomic Habits</em> is how these small changes create a ripple effect in other areas of life. For example, by starting a morning routine that includes meditation and exercise, I’ve noticed improvements in my focus, energy levels, and overall mood. These positive changes have spilled over into my work, relationships, and personal growth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*uyTgk4Fsu6xQtzKI" /></figure><h3>Final Thoughts</h3><p><em>Atomic Habits</em> has taught me that transformation doesn’t happen overnight. It’s the result of small, consistent actions repeated over time. By focusing on 1% improvements, understanding the habit loop, and aligning my habits with my desired identity, I’ve been able to make meaningful changes in my life.</p><p>If you’re feeling stuck or overwhelmed, I highly recommend picking up <em>Atomic Habits</em>. It’s not just a book; it’s a roadmap for building a better life, one tiny habit at a time. Remember, you don’t have to be perfect — you just have to be consistent. As James Clear says, “You do not rise to the level of your goals. You fall to the level of your systems.” So, start small, stay consistent, and watch your life transform.</p><p>What about you? Have you read <em>Atomic Habits</em>? How has it impacted your life? Let me know in the comments — I’d love to hear your story!</p><p>With love,<br>Bhuvaneshwari Kanagaraj</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3f9d79075d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PART 1 — Planning + Smart Execution: The Ultimate Guide to Owning Your 2025]]></title>
            <link>https://medium.com/@bhuvaneshwarii026/part-1-planning-smart-execution-the-ultimate-guide-to-owning-your-2025-b6b20351992c?source=rss-66e2c8838299------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6b20351992c</guid>
            <dc:creator><![CDATA[bhuvaneshwari kanagaraj]]></dc:creator>
            <pubDate>Thu, 26 Dec 2024 08:10:37 GMT</pubDate>
            <atom:updated>2024-12-26T08:10:37.349Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PrddgzD6aar3nwgpz57CbA.jpeg" /></figure><h3>PART 1 — Planning + Smart Execution: The Ultimate Guide to Owning Your 2025</h3><p>Hi everyone, Bhuv here! While you might know me for my technical explorations, today, I’m breaking that pattern😂. As we approach the new year, I’ve been reflecting on how 2025 could be my year of transformation. This isn’t just about dreaming big; it’s about planning smart and executing even smarter.</p><h3>Why Planning Alone Isn’t Enough</h3><p>You’ve probably heard the adage: <em>Failing to plan is planning to fail.</em> While this is true, I’d argue that planning without proper execution is just wishful thinking. The real magic lies in combining a clear plan with disciplined, smart execution.</p><p>When I started sketching out my vision for 2024 , I decided not to leave it as just a pretty board of ideas. It became a roadmap that I revisit every morning. Let me share how you can craft and execute your vision too.</p><h3>My Vision Board Experience: September 2024</h3><p>In September 2024, I took the leap and created my own vision board for the next 8 months. It was a transformative experience! Here’s why:</p><ul><li><strong>Every Picture Tells a Story</strong>: Each image on the board resonated with my goals — whether it was career milestones, personal growth, or travel dreams.</li><li><strong>Morning Motivation</strong>: Looking at the board every morning has been a game-changer. It’s not just inspiring; it’s empowering.</li></ul><p>Creating the board wasn’t just fun; it was a moment of clarity. Seeing my goals visually laid out gave me a sense of purpose and direction. And trust me, it’s not bragging! It’s about aligning your dreams with actionable steps.</p><h3>Execution in Action: My Solo Trip to Vizag</h3><p>Speaking of goals and execution, let me share a recent milestone. I had the opportunity to speak in Vizag, India — the City of Mountains and Beaches. It was a monumental experience for a few reasons:</p><ul><li><strong>First Solo Trip</strong>: This was my first time traveling solo, and it taught me so much about independence and resilience.</li><li><strong>Sponsored Flights</strong>: My flights were fully sponsored, which was a proud moment for me.</li><li><strong>Meaningful Connections</strong>: I made incredible connections throughout the trip, expanding my personal and professional network.</li></ul><p>I truly believe this happened because of strong planning and execution. It wasn’t just a fluke; it was the result of setting clear intentions and working consistently toward them.</p><h4>1. <strong>Start with Goal Setting</strong></h4><p>This marks my second year of actively writing down my goals.</p><p>It’s a simple step you can begin today — grab a notebook or open a digital tool and jot them down.</p><p>This is something you can start today itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/0*xUxQ-vIWA_Shzcim.png" /><figcaption><a href="https://www.smartsheet.com/blog/essential-guide-writing-smart-goals">https://www.smartsheet.com/blog/essential-guide-writing-smart-goals</a></figcaption></figure><h4>2. Create a Vision Board</h4><p>You don’t need to overcomplicate this process. Whether it’s a physical board or a digital wallpaper, find images that represent your goals. For inspiration, platforms like Pinterest are a great place to start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*nWkWOxxSCuHh6x13FP64hg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/0*MBn87gf0R-ItUopP.jpg" /><figcaption>(Left image)Me and My board , (right image) Phone Wallaper reference</figcaption></figure><h4>3. Cultivate the Right Mindset</h4><p>Your mindset shapes your journey. For me, working toward a better version of myself turned into a deep obsession. It’s easy to start, but execution is where many falter.</p><p>One practice that’s helped me is <strong>elastic habits</strong> — a flexible approach to achieving goals. On days when exercising feels daunting, I simply complete 12 rounds of surya namaskar before moving to the next task. The focus is on progress, not perfection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BRkkPUWjOJBmtNTf.jpg" /><figcaption><a href="https://www.amazon.in/Elastic-Habits-Create-Smarter-Adapt-ebook/dp/B08188WBGC">https://www.amazon.in/Elastic-Habits-Create-Smarter-Adapt-ebook/dp/B08188WBGC</a></figcaption></figure><h4>4. Use scheduling tools to track your work.</h4><p>Sorry for blurring the calendar, but this is how my calendar looks. I use Google Calendar to plan my day and track task completion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FY0m7U1DIjWXcAcY0NjFPA.png" /></figure><p>One thing I follow is blocking a time slot and completing the tasks within the calendar itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N1UxCiN-nphL5DvjeprUAg.png" /></figure><p>These are the things I wanted to share. Try implementing them, and feel free to leave your comments if you have any. Thanks for reading!</p><h3>Final Thoughts</h3><p>These are strategies that have worked for me, and I hope they resonate with you too. Planning smart and executing with discipline can make 2025 a year of significant achievements.</p><p>Thank you for reading! Let me know your thoughts and if you’ve tried implementing any of these ideas.</p><p>Wishing you a fantastic 2025! ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6b20351992c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with seL4: Printing “Hello, World!”]]></title>
            <link>https://medium.com/@bhuvaneshwarii026/getting-started-with-sel4-printing-hello-world-ff4010081072?source=rss-66e2c8838299------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff4010081072</guid>
            <dc:creator><![CDATA[bhuvaneshwari kanagaraj]]></dc:creator>
            <pubDate>Mon, 14 Oct 2024 03:32:37 GMT</pubDate>
            <atom:updated>2024-10-14T03:32:37.175Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, I’ll guide you through each step to set up seL4, compile, and run your first program on it — printing <strong>“Hello, World!”</strong>. I’ll break down every command and process so you understand what you’re doing and why it’s important.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*1TacRaFpDXANMonSz6fKGw.png" /></figure><h3>Step 1: Setting Up the Environment with sel4-tutorials-manifest</h3><p>The first thing you need to do is set up a working environment using <strong>seL4 tutorials</strong>. These tutorials provide a foundation for working with the seL4 microkernel. Let’s begin with the following commands:</p><h4>1.1 Create a Directory for the Tutorial Manifest</h4><pre>mkdir sel4-tutorials-manifest<br>cd sel4-tutorials-manifest</pre><p>Here, we are creating a directory to house the seL4 tutorial files and moving them.</p><h4>1.2 Initialize the Repository and Syn</h4><pre>repo init -u https://github.com/seL4/sel4-tutorials-manifest<br>repo sync</pre><ul><li>repo init: This initializes a Git repository using the seL4 tutorial manifest hosted on GitHub.</li><li>repo sync: Syncs the files from the remote repository into your local directory.</li></ul><p>You now have all the necessary files to start working with the seL4 tutorials.</p><p>here is the Repository Structure,</p><ul><li><strong>seL4 Core</strong><br>The microkernel is at the heart of everything.</li><li><strong>Tutorials</strong><br>Folders containing specific exercises like <em>hello-world</em> or <em>IPC</em>.</li><li><strong>Build System</strong><br>Shows the repo manifest, build scripts, and necessary toolchains.</li></ul><h3>Step 2: Creating a Python Virtual Environment</h3><p>A Python virtual environment isolates dependencies and tools, preventing potential conflicts with the system’s global packages.</p><h4>2.1 Create the Virtual Environment</h4><pre>python3 -m venv venv</pre><ul><li>python3 -m venv venv: This creates a virtual environment called venv. It will be an isolated environment where you can install all required Python dependencies for seL4.</li></ul><h4>2.2 Activate the Virtual Environment</h4><pre>source venv/bin/activate</pre><ul><li>source venv/bin/activate: This command activates the virtual environment, making sure any Python packages installed are only available in this environment.</li></ul><h4>2.3 Install seL4 Dependencies</h4><p>Once the virtual environment is activated, you need to install dependencies for seL4 and CAmkES (Component Architecture for Microkernel-based Embedded Systems).</p><pre>pip3 install setuptools<br>pip3 install sel4-deps<br>pip3 install camkes-deps</pre><ul><li>pip3 install setuptools: Installs the Python setup tools package (required to build Python packages).</li><li>sel4-deps: Contains the necessary dependencies for seL4.</li><li>camkes-deps: Adds dependencies required for CAmkES, which is used for componentized systems in seL4.</li></ul><h4>2.4 Install Additional Packages (if required)</h4><pre>pip install aenum<br>pip install sh</pre><p>If you encounter any missing dependency issues during the process, the above packages might be needed.</p><h4>2.5 Deactivate the Virtual Environment (Optional)</h4><pre>deactivate</pre><p>This command deactivates the virtual environment, reverting the shell to its normal state. You’ll need to reactivate it when running or building programs.</p><h3>Step 3: Initialize and Build Your First Program</h3><p>With the environment ready, let’s start the “Hello, World!” program.</p><h4>3.1 Initialize the Hello World Tutorial</h4><pre>./init --tut hello-world<br>cd hello-world_build</pre><ul><li>./init --tut hello-world: Initializes the &quot;Hello, World!&quot; tutorial project.</li></ul><pre>#include &lt;stdio.h&gt;<br>#include &lt;sel4/sel4.h&gt;<br><br>int main(void) {<br>    // Print Hello World to the standard output<br>    printf(&quot;Hello, World!\n&quot;);<br><br>    // Return success<br>    return 0;<br>}</pre><p>Please note you don&#39;t have to write this code separately, we have it already there in the directory.</p><p>The init script prepares everything needed to build the project. By specifying the hello-world tutorial, you are setting up the project to run the specific tutorial for printing &quot;Hello, World!&quot;.</p><h4>3.2 Build the Project</h4><pre>ninja</pre><ul><li>ninja: This command compiles the code using the <strong>Ninja build system</strong>. It’s an efficient build tool that quickly compiles and links your code.</li></ul><p>After running this command, the program will be compiled, and the binary will be created.</p><h4>3.3 Cleaning the Build (Optional)</h4><pre>ninja clean</pre><ul><li>ninja clean: This removes the generated files from the build directory, effectively cleaning the workspace.</li></ul><p>If you ever need to rebuild from scratch, you can use this to clean the current build.</p><h3>Step 4: Running the Program in QEMU</h3><h4>4.1 Run the Simulation</h4><pre>./simulate</pre><ul><li>./simulate: This command runs the compiled &quot;Hello, World!&quot; program on the <strong>QEMU</strong> emulator. QEMU emulates hardware, allowing you to run the program without needing real hardware.</li></ul><p>Once you run this command, you should see the system booting and eventually printing the following</p><pre>Booting all finished, dropped to user space<br>Hello, World!</pre><h4>4.2 Exiting QEMU</h4><p>To exit QEMU, use the following key combination:</p><pre>Ctrl-A, X</pre><p>This will stop the emulator and return you to the terminal.</p><p>This simple exercise is a great first step toward understanding how to interact with seL4, a powerful and highly secure microkernel. From here, you can dive deeper into system-level programming, explore more complex interactions, and start building secure, reliable applications on top of seL4.</p><p>See you in the next blog!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff4010081072" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why is seL4 more popular? — The Only Mathematically Proven Microkernel]]></title>
            <link>https://medium.com/@bhuvaneshwarii026/why-is-sel4-more-popular-the-only-mathematically-proven-microkernel-8ffe6a6101ed?source=rss-66e2c8838299------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ffe6a6101ed</guid>
            <dc:creator><![CDATA[bhuvaneshwari kanagaraj]]></dc:creator>
            <pubDate>Thu, 03 Oct 2024 19:03:24 GMT</pubDate>
            <atom:updated>2024-10-04T03:11:09.409Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why is seL4 Gaining Popularity? — The World’s Only Mathematically Verified Microkernel</h3><p>Hi, it’s been some time since I started exploring embedded development at the kernel level. During this journey, I came across <strong>seL4</strong>, a high-assurance microkernel that’s been making waves in the world of embedded systems and secure computing 🔐.</p><p>This blog will give you an abstract view of seL4, explain how to get started with it, and compare it briefly with other L4 microkernels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2EkZ6NgTcnE0LVgwLKOeGw.png" /><figcaption>Yes, the seL4 microkernel consists of approximately 9,000 lines of code.</figcaption></figure><h3>What is the actual difference between a microkernel and a traditional kernel?</h3><p>A <strong>kernel</strong> is the core part of an operating system that manages resources and services, typically being larger and more integrated. In contrast, a <strong>microkernel</strong> is a minimal version that only includes essential functions, running additional services in user space, making it more modular, secure, and fault-tolerant but potentially less performant due to context switching.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VgsaeQkkLqy6E0zGlKmZww.png" /><figcaption>This is what a kernel handle versus what a microkernel handles</figcaption></figure><p><strong>seL4</strong> is a member of the <strong>L4 microkernel family</strong>, and it’s designed to be minimal yet powerful, with a focus on formal verification, high security, and efficiency. What makes seL4 stand out is its mathematically proven correctness, ensuring that critical aspects like memory safety, isolation, and access control behave exactly as expected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8NBgHCTSfB1c8S0yWfBXag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HfhNUG1TPq5R_KxH71Vw5g.png" /><figcaption>More functionalities are shifted to user space. Do we really need all device drivers at the kernel level? That’s the question seL4 addresses.</figcaption></figure><p>seL4 is often used in embedded systems, IoT devices, autonomous systems, and critical infrastructure where security and robustness are paramount.</p><p>Due to its small codebase and high assurance guarantees, it serves as an excellent choice for building secure systems, hypervisors, and real-time systems.</p><h3>What are some key reasons to consider seL4 when building real-time applications?</h3><ul><li><strong>Formal Verification</strong>: seL4 is one of the few microkernels that have been formally verified, meaning that its behavior is mathematically proven to adhere to its specifications.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6z_0zLOSg6b-aAbbZpyniA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nsqzrBnBFnVbzw56DyYmbA.png" /><figcaption>(1) <a href="https://tinyurl.com/44w6mb4v">https://tinyurl.com/44w6mb4 v</a>(2)<a href="https://github.com/seL4">https://github.com/seL4</a></figcaption></figure><ul><li><strong>Security and Isolation</strong>: It guarantees strong isolation between processes, making it a secure platform for systems requiring multiple virtual machines or separate critical processes.</li><li><strong>Capability-based Access Control</strong>: The kernel uses a capability-based system to control resource access, ensuring that only authorized processes can interact with sensitive system parts.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fFgZq0FkxgXRXyWOCRyq8w.png" /><figcaption>The Real Time Game</figcaption></figure><h3>Running seL4: Getting Started</h3><p>Here’s an abstract view of the various methods you can use to run seL4 on different platforms.</p><h4>1. Running seL4 on QEMU</h4><ul><li><strong>QEMU</strong> is a popular emulator that lets you run seL4 on various architectures like ARM or x86, without requiring real hardware.</li><li>This method is ideal for development and testing, where you can easily emulate target hardware environments on your host machine.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7oJ3m8j8Bu47yHgO8-VoTA.png" /><figcaption>Qemu: Quick Emulator, emulates architectures like X86, ARM and PowerPC</figcaption></figure><h4>2. Running seL4 on Real Hardware</h4><ul><li>seL4 can run on real hardware like ARM Cortex-A series processors or platforms like Raspberry Pi.</li><li>Cross-compiling for specific hardware and booting via SD cards or UART for debugging are common steps when running on real hardware.</li></ul><h4>3. Running seL4 on Virtual Machines (VirtualBox or VMware)</h4><ul><li>Virtual Machines (VMs) like <strong>VirtualBox</strong> or <strong>VMware</strong> can also be used to run seL4, though it’s less common compared to QEMU.</li><li>Similar to QEMU, you’d configure the VM to emulate the necessary architecture and load the compiled seL4 kernel.</li></ul><h3>Using seL4 as a Hypervisor</h3><p>One of the powerful use cases of <strong>seL4</strong> is its capability to serve as a hypervisor, managing virtual machines with strong isolation and security. Here’s an overview of how it can function in this role</p><blockquote>A hypervisor, also known as a virtual machine monitor (VMM), is software that creates and manages virtual machines (VMs) on a host system. It allows multiple operating systems to run on the same hardware by abstracting the underlying physical resources, such as CPU, memory, and storage. Hypervisors can be classified into two types:</blockquote><blockquote><strong>Type 1 (Bare-Metal Hypervisor):</strong> Runs directly on the hardware and manages guest operating systems, such as VMware ESXi and Microsoft Hyper-V.</blockquote><blockquote><strong>Type 2 (Hosted Hypervisor):</strong> Runs on a host operating system and manages virtual machines, such as VMware Workstation or VirtualBox.</blockquote><h4>1. seL4 as a Hypervisor</h4><ul><li>seL4 can act as a host kernel, controlling virtual machines (VMs) and managing resources like memory, CPU, and I/O.</li><li>It provides a strong separation between guest VMs, making it ideal for secure multi-OS environments in embedded systems.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4qjqzx6qDFmFO_4u99tXug.png" /><figcaption>seL4 acts as a hypervisor, securely isolating virtual machines on shared hardware.</figcaption></figure><h4>2. Running Guest OSes on seL4</h4><ul><li>Guest operating systems like <strong>Linux</strong> can run on top of seL4, utilizing its virtualization capabilities for secure and isolated environments.</li></ul><h4>3. Testing Hypervisor Setup on QEMU</h4><ul><li>For development purposes, QEMU can be used to emulate seL4 as a hypervisor, allowing you to run guest OSes in a virtual environment for testing without requiring actual hardware.</li></ul><h3>Other L4 Microkernels: A Brief Overview</h3><p>The <strong>L4 microkernel family</strong> consists of several variants, all designed for similar purposes but with varying levels of focus on security, performance, and formal verification.</p><h4>1. L4Ka:</h4><ul><li>Developed as a research microkernel, <strong>L4Ka</strong> focuses on scalability and performance, particularly in distributed systems.</li></ul><h4>2. L4/Fiasco:</h4><ul><li><strong>Fiasco</strong> is an L4 microkernel that supports real-time systems and includes features like multiprocessor support and virtualization.</li></ul><h4>3. L4Re:</h4><ul><li><strong>L4Re</strong> (L4 Runtime Environment) is a user-friendly variant of the L4 microkernel, offering a development environment for building applications and systems on top of L4.</li></ul><h4>4. Pistachio L4:</h4><ul><li>A research version of the L4 microkernel, <strong>Pistachio</strong> aimed to bring portability to the L4 family, supporting multiple hardware platforms.</li></ul><p>Get started with Sel4 tutorials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D7NX7B2GbQ5U1GlCDCLTEA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*66uMFRM8Mw-21EY9A_emrQ.png" /><figcaption><a href="https://docs.sel4.systems/Tutorials/">https://docs.sel4.systems/Tutorials/</a></figcaption></figure><p><strong>In conclusion</strong>, <strong>seL4</strong> stands out as a high-assurance microkernel, perfect for secure embedded systems and IoT applications. Its capability-based access control and formal verification provide unmatched security and efficiency. Whether you’re starting with QEMU or real hardware, seL4’s hypervisor capabilities open the door to creating reliable, isolated environments.</p><p>Stay tuned — I’ll be back with more insights in the next post!👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ffe6a6101ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AVR Microcontroller Programming Handy with Cheat Sheet!]]></title>
            <link>https://medium.com/@bhuvaneshwarii026/avr-microcontroller-programming-handy-with-cheat-sheet-a315abdbd1a1?source=rss-66e2c8838299------2</link>
            <guid isPermaLink="false">https://medium.com/p/a315abdbd1a1</guid>
            <dc:creator><![CDATA[bhuvaneshwari kanagaraj]]></dc:creator>
            <pubDate>Sat, 20 Jul 2024 03:57:26 GMT</pubDate>
            <atom:updated>2024-07-20T03:57:26.700Z</atom:updated>
            <content:encoded><![CDATA[<p>Explore essential commands and tips for AVR-GCC and AVRdude.</p><p>What you will find?</p><p>✅ Compilation and Linking: Learn to compile and link AVR projects efficiently.<br>✅ LFUSE Programming: Set LFUSE for an internal 8MHz crystal oscillator.<br>✅ Hex File Programming: Step-by-step guide to program intel .hex file formats onto AVR microcontrollers.<br>✅ Optimization Tips: Understand -Os optimization for smaller executable sizes.<br>✅ Installation Instructions: Quick setup guide for AVR-GCC on macOS and Linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_CAERI8b7AcvJJNmgKNCw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a315abdbd1a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bare-Metal MCU #7: Libraries (Preprocessor & Linker)]]></title>
            <link>https://medium.com/@bhuvaneshwarii026/bare-metal-mcu-7-libraries-preprocessor-linker-f87de4208303?source=rss-66e2c8838299------2</link>
            <guid isPermaLink="false">https://medium.com/p/f87de4208303</guid>
            <dc:creator><![CDATA[bhuvaneshwari kanagaraj]]></dc:creator>
            <pubDate>Tue, 16 Jul 2024 06:38:28 GMT</pubDate>
            <atom:updated>2024-07-16T06:38:28.932Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi everyone, I’m back with my latest blog post! Today, our focus is on preprocessors and linkers, aiming to effectively utilize libraries in our projects.</p><h4>Preprocessor</h4><pre>#define BHUVANESHWARI 2</pre><p>Here, it instructs to find “BHUVANESHWARI” with 2. It’s conventional to write keywords in all caps in order for others to recognize the use of a preprocessor macro.</p><p><strong><em>It ‘s AUTOMATED COPY/PASTE</em></strong></p><p>Why do we want to use this?</p><ol><li>Commonly used to make code more readable</li></ol><pre><br>#define LED_BUILTIN 13<br>#define OUTPUT 1<br><br>void setup(){<br>pinMode(LED_BUILTIN, OUTPUT)<br>}<br></pre><p>If you ask why not just use variables — they occupy RAM, whereas #define does not.</p><p>2. We have to be much more responsible while using #define</p><pre>#define LED_BUILTIN 13;<br>#define OUTPUT 1;<br><br>void setup(){<br>pinMode(LED_BUILTIN, OUTPUT)<br>}</pre><p>So, it means that</p><pre>pinMode(13;,1;);</pre><p>I’m currently working on two files, where one will be included within the other. Feel free to use any names you’d like me to use for these files.</p><pre>#define PORTB *((volatile unsigned char*) 0x25)<br>#define DDRB *((volatile unsigned char*) 0x24)<br><br>int main() {<br><br>DDRB = 32;<br><br>while(1);<br><br>{<br>  #include &quot;mainloop.txt&quot;<br>}<br>}<br></pre><p>Let&#39;s peek inside mainloop.txt,</p><pre><br>for(long i=0; i&lt; 1000000; i++) { PORTB =32;}<br>for(long i=0; i&lt; 1000000; i++) { PORTB =0;}<br></pre><p>Essentially, we are incorporating the code from the “for-loop” file into the main file.</p><p>For compilation with avr-gcc please check my previous blog — <a href="https://medium.com/@bhuvaneshwarii026/bare-metal-mcu-6-compilers-assemblers-and-friends-7476a1044120">https://medium.com/@bhuvaneshwarii026/bare-metal-mcu-6-compilers-assemblers-and-friends-7476a1044120</a></p><h4>Libraries</h4><p>Since we can’t directly use the delay() function, we&#39;ll create a library where we can utilize it. Here&#39;s our main.c file:</p><pre>#define PORTB *((volatile unsigned char*) 0x25)<br>#define DDRB *((volatile unsigned char*) 0x24)<br>#include &quot;loop.c&quot;<br><br>int main() {<br><br>DDRB = 32;<br><br>while(1);<br><br>{<br>  PORTB =32;<br>  delay(1000);<br>  PORTB =0; <br>  delay(1000);<br>}<br>}</pre><p>Here’s our loop.c file:</p><pre>void delay(volatile long time){<br>  while (time! =0){<br>    time--;<br>    }<br>}</pre><h4>Linkers</h4><p>A <strong>linker</strong> is a software utility that takes one or more object files generated by a compiler and combines them into a single executable file, library, or another object file. The linker resolves references between the object files, combines them into a single address space, and performs any necessary address and offset calculations to create a functional executable.</p><pre>#include &lt;Wire.h&gt;<br>#include &lt;Adafruit_Sensor.h&gt;<br>#include &lt;Adafruit_BME280.h&gt;<br><br>// Define sensor object<br>Adafruit_BME280 bme;<br><br>void setup() {<br>  Serial.begin(9600);<br>  if (!bme.begin(0x76)) {<br>    Serial.println(&quot;Could not find a valid BME280 sensor, check wiring!&quot;);<br>    while (1);<br>  }<br>}<br><br>void loop() {<br>  Serial.print(&quot;Temperature = &quot;);<br>  Serial.print(bme.readTemperature());<br>  Serial.println(&quot; *C&quot;);<br>  delay(2000);<br>}</pre><p>The linker combines your sketch’s object file with the object files from the Wire library and the Adafruit_BME280 library, resolving function calls like bme.begin() and bme.readTemperature().</p><p>okay, let&#39;s take that you are including these in the main.c file,</p><pre>#include &quot;gpio.c&quot;<br>#include &quot;timming.c&quot;<br>#include &quot;serial.c&quot;<br>#include &quot;lcd.c&quot;</pre><p>What happens during the compilation process? Actual gpio.c will be added to your main.c and then finally, it will be compiled.</p><p>This is my updated bhuvaneshwari.c file</p><pre>  UW PICO 5.09                File: bhuvaneshwari.c                  <br><br>#define PORTB *((volatile unsigned char*) 0x25)<br>#define DDRB *((volatile unsigned char*) 0x24)<br><br>void delay(long);<br><br>int main() {<br><br>DDRB = 32;<br><br>while(1);<br><br>{<br>  PORTB = 32;<br>  delay(1000000);<br>  PORTB = 0;<br>  delay(1000000);<br>}<br>}<br><br></pre><p>Here goes my lib.c function for the delay,</p><pre>void delay(volatile long time){<br>  while(time != 0){<br>    time--;<br>    }<br>}</pre><p>Here void delay(long); is one of my prototypes. A prototype is one of hint to my compiler.</p><pre>avr-gcc -c -mmcu=&lt;microcontroller&gt;</pre><p>Compilers don&#39;t link. By default, avr-ggc run the linker. We can add the -c flag to do a compile-only operation.</p><ul><li><strong><em>-C</em></strong><em> Complies or assembles the source file, but does not link. The Linking stage simply is not done. The ultimate output is in the form of an object file for each source file.</em></li></ul><pre>avr-gcc -c -mmcu=atmega328 bhuvaneshwari.c   <br>avr-gcc -c -mmcu=atmega328 lib.c</pre><pre><br>// We are actualy with linker file<br><br>avr-gcc -mmcu=atmega328 bhuvaneshwari.o lib.o<br><br>//This will give you a.out</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ppdx4lHT6oTzTF4QlF151g.png" /></figure><p>This process produces the final executable file that we will load onto our microcontroller.</p><pre>avr-gcc -c -mmcu=atmega328 bhuvaneshwari.c</pre><p>This will throw an error because we need to declare a prototype. If you’re not sure about the file name, we can handle that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zSBDX60RTxJGMI0qRRlbCw.png" /></figure><p>Here, I included the linked file and then compiled everything together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ByBwGRjZeQ7SEIht7lGWqA.png" /></figure><p>Adding all the prototypes individually can indeed be cumbersome. One approach to streamline this is to consolidate all prototypes into a single header file. This helps manage and simplify the inclusion of function declarations across multiple files.</p><p>From the main.c file we shall move it to a file something common call allprototypes.c</p><pre>void delay(long)<br>void pinMode(int,int)<br>void digitalWrite(int, int)</pre><p>Now we will create a header for each library.</p><p>We have a file called lib.c and we will create lib.h which will handle all the prototypes for lib.c</p><p>Now rather than adding all the prototypes to the main.c we will add it here.</p><p>Take this case, where timming.h is been called twice?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HVOLRiURRs_qNn97IJtBHg.png" /></figure><p>It looks something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*uOtb5YQmoi5PoGE3hBpOdA.png" /></figure><p>Duplication of code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*ox3WX-5F4Hop30DxQOU1bw.png" /></figure><p>#ifndef is a preprocessor directive in C and C++ that stands for &quot;if not defined.&quot; It&#39;s used in conjunction with #define and #endif to create an include guard prevents a header file from being included multiple times in a single compilation unit. This helps avoid issues like redefinition errors and numerous symbol definitions.</p><h3>Complete Example</h3><p>Here’s a complete example with two header files and a source file:</p><p><strong>File: </strong><strong>example.h</strong>:</p><pre>#ifndef EXAMPLE_H<br>#define EXAMPLE_H<br>void exampleFunction();<br>#endif // EXAMPLE_H</pre><p><strong>File: </strong><strong>main.cpp</strong></p><pre>#include &quot;example.h&quot;<br>int main() {<br>    exampleFunction();<br>    return 0;<br>}</pre><p><strong>File: </strong><strong>example.cpp</strong>:</p><pre>#include &quot;example.h&quot;<br>#include &lt;iostream&gt;<br>void exampleFunction() {<br>    std::cout &lt;&lt; &quot;Hello, world!&quot; &lt;&lt; std::endl;<br>}</pre><p>In this example, the include guard in example.h ensures that the content of example.h is included only once, even if example.h is included in multiple files or multiple times in the same file.</p><p>Thanks see you in the next blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f87de4208303" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bare-Metal MCU #6: Compilers, Assemblers, and Friends]]></title>
            <link>https://medium.com/@bhuvaneshwarii026/bare-metal-mcu-6-compilers-assemblers-and-friends-7476a1044120?source=rss-66e2c8838299------2</link>
            <guid isPermaLink="false">https://medium.com/p/7476a1044120</guid>
            <dc:creator><![CDATA[bhuvaneshwari kanagaraj]]></dc:creator>
            <pubDate>Sun, 14 Jul 2024 05:08:12 GMT</pubDate>
            <atom:updated>2024-07-14T05:08:12.212Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we’ll delve into the compilation process specific to Arduino. This exploration aims to provide informative insights.</p><p>Let’s illustrate how a compiler transforms human-readable code into machine code. We’ll take a sample piece of code and examine its conversion through each stage of the compilation process.</p><p><strong>main. c</strong></p><pre>i =i+1</pre><p><strong>main.asm</strong></p><pre>lds r24, 22<br>adiw r24, 1<br>sts 22, r24</pre><p>Assembly language can be translated directly into machine code, a process typically performed by a program called an Assembler. Alternatively, if you’re daring, you can also translate assembly language into machine code manually.</p><p><strong>main.hex</strong></p><p>If you’re curious about how this hex code suddenly appeared, let me explain. We’ll refer to the datasheet for clarification.</p><p>Let’s take the instruction <strong><em>adiw r24, 1 </em></strong>and convert it into hexadecimal. I found this instruction set information in the datasheet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k7Wk7iu3MvwWUlW9eDGmxA.png" /><figcaption>From Datasheet</figcaption></figure><p>Okay, what they mentioned here is some immediate number is being added to a word. For AVR, a word is. a 16-bit number (Stored in two 8-bit registers)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*Wsp6TZcE87spIyrTWbvWjQ.png" /><figcaption>From Datasheet</figcaption></figure><p>We should note that operations can only be performed with registers 24, 26, 28, and 30.</p><pre>We should add 1 to register 24.<br>opcode = 1001 0110<br>d = [00]<br><br>Explaination why d = 0[00]<br>Actually 0 = 00, 1 = 01, 2 = 10, 3 = 11<br>0 = 00 (user r24)<br>1 = 01 (user r26)<br>2 = 10 (user r28)<br>3 = 11 (user r30)<br><br>one in 8 bit can be represented by this<br><br>1 = 0000 0001<br><br>finaly if we want to add 1 to the register, and looking at the 16-bit opcode<br><br>1001 0110 0000 0001</pre><pre>1001 0110 0000 0001 in hex is 0x9601</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*wnj2rcrXwb0o6JeIhAcPRw.png" /><figcaption>click on View&gt;Programmer in mac</figcaption></figure><p>We got 96 01 right we are writing this as 01 96? That’s a good question 0x9601 is entered as [0196] because AVR expects the smallest byte first.</p><p>This process is called “byte ordering” or “endianness.” Specifically, when storing or transmitting multi-byte data, endianness determines the order in which bytes are arranged in memory or a data stream. In the context of AVR microcontrollers and many other architectures, it uses “little-endian” byte ordering. This means that the least significant byte (LSB) is stored at the lowest memory address or transmitted first, followed by the most significant byte (MSB). Therefore, the hexadecimal value 0x9601 is stored as [01][96] in little-endian format on AVR microcontrollers.</p><pre>80 91 16 00<br>01 96 80 93<br>16 00</pre><p>To compile C-based code into AVR-based machine code for Arduino, let’s explore how Arduino utilizes this process.</p><p>If you’re using a Mac, you can install avr-gcc by executing the following commands:</p><pre>brew tap osx-cross/avr<br>brew install avr-avr</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y2hPN8TxYRP5oGiguq6ZGw.png" /><figcaption>The installation took me 5 to 6 mins!</figcaption></figure><p>if you are on Linux,</p><pre>sudo apt-get install gcc-avr</pre><p>In the ATmega328 family, all members follow the AVR5 instruction set. If the instruction set is not explicitly specified, the compiler defaults to using the AVR2 instruction set.</p><p>With this understanding, let’s proceed to run a basic compilation command for a bare-bones setup.</p><pre>avr-gcc -mmcu=&lt;microncontroller&gt; &lt;sourceFile&gt;<br>avr-gcc -mmcu=atmega328 dummy.c</pre><p>When compiling C code with avr-gcc, the default output filename is a.out unless specified otherwise using the -o &lt;outputName&gt; flag.</p><p>Here are some adjustments needed for AVR development:</p><ul><li>Replace byte with unsigned char* to align with AVR-GCC requirements.</li><li>Use main() instead of void loop() and void setup(), as AVR-GCC expects a standard main() function for execution.</li><li>Utilize macros for efficient memory usage and code optimization.</li></ul><p>These adjustments ensure compatibility and efficiency when developing AVR microcontrollers using avr-gcc.</p><pre>#define PORTB *((volatile unsigned char*) 0x25)<br>#define DDRB *((volatile unsigned char*) 0x24)<br><br>int main() {<br><br>DDRB = 32;<br><br>while(1);<br><br>{<br>  PORTB = 32; // Set PB5 HIGH (turn on LED)<br>  for(long i=0; i&lt; 1000000; i++) { PORTB = 32; }<br>  PORTB = 0; // Set PB5 LOW (turn off LED)<br>  for(long i=0; i&lt; 1000000; i++) { PORTB = 32; }<br><br>}<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RVKC82DVlMDknhwFSN4ICA.png" /><figcaption>Can you see a.out?</figcaption></figure><p>a.out is technically a machine code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kj3JRXTWAjRHbkuTgnXr0Q.png" /><figcaption>a.out file</figcaption></figure><p>We have something called avr-objcopy which helps in this conversion process (From Bin to Hex)</p><pre>avr-objcopy -O ihex a.out a.hex</pre><p>The output format is “intel Hex”, which is something AVRDude supports. a.out is the file generated by compiling dummy.c with avr-gcc</p><p>a.hex is the file that we want as the output.</p><pre>avr-objcopy -O ihex a.out a.hex<br><br>// We need only the text and data to to be converetd<br><br>avr-objcopy -O ihex -j.text -j.data a.out a.hex </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TfreSZl6JURGbS_jKatkIA.png" /><figcaption>inside a.hex</figcaption></figure><p>Please note that if you have any questions about using shell and bash commands beyond what’s covered in this blog, feel free to ask. I’ll be happy to assist you with any related queries you may have in another context or post.</p><pre>./avrdude -C ../etc/avrdude.conf -p atmega328 -c stk500v1 <br>-P /dev/cu.usbmodem1301 -B5 <br>-U flash:w:a.hex</pre><p>If you are encountering issues like this,</p><pre>avrdude: device signature = 0x000000 (retrying)<br>avrdude: device signature = 0x000000 (retrying)<br>avrdude: device signature = 0x000000<br>avrdude error: Yikes!  Invalid device signature.<br>avrdude error: expected signature for ATmega328 is 1E 95 14<br>        Double check connections and try again, or use -F to override<br>        this check.</pre><p>Then please use this command,</p><pre><br>./avrdude -C ../etc/avrdude.conf -p atmega328 <br>-c stk500v1 -P /dev/cu.usbmodem1301 -B5 <br>-U flash:w:a.hex -F</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jt-7d7RWQ3M-HOOJJzX8RA.png" /><figcaption>Uploaded!</figcaption></figure><p>That’s all for today. See you in the next blog!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7476a1044120" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bare-Metal MCU #5 — AVRDude and fuses]]></title>
            <link>https://medium.com/@bhuvaneshwarii026/bare-metal-mcu-5-avrdude-and-fuses-c0919cb4b729?source=rss-66e2c8838299------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0919cb4b729</guid>
            <dc:creator><![CDATA[bhuvaneshwari kanagaraj]]></dc:creator>
            <pubDate>Sat, 13 Jul 2024 08:22:32 GMT</pubDate>
            <atom:updated>2024-07-13T08:22:32.341Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bare-Metal MCU #5 — AVRDude and fuses</h3><p>Welcome to day 5 of Learning Bare Metal Coding! Today, our objective is to eliminate the need for an external capacitor and crystal oscillator.</p><p>You might wonder, “How can we program without a clock?” Well, here’s the deal: our microcontroller comes equipped with a built-in 8MHz crystal oscillator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HniltoGRru24gA6wE3M-Kg.png" /></figure><p>To achieve this, a clear understanding of ISP (In-System Programming) with another Arduino is crucial. Fuses play a vital role in this process.</p><blockquote><strong><em>In the ATmega328P IC, there are a total of 19 fuse bits and they are divided into three fuse bytes. Those are defined as “Extended Fuse Bytes”, “High Fuse Bytes”, and the “Low Fuse Bytes”</em></strong></blockquote><blockquote>These are the various fuse bytes used in AVR microcontrollers like those found in Arduino boards:</blockquote><blockquote><strong>1. Low Fuse:</strong> Controls fundamental settings such as clock source selection, startup time, and brown-out detection level.</blockquote><blockquote><strong>2. High Fuse</strong>: Manages settings related to bootloader size, external memory handling, and JTAG interface configuration.</blockquote><blockquote><strong>3. Extended Fuse</strong>: Specifies additional parameters such as brown-out detection settings, watchdog timer configuration, and clock output options.</blockquote><blockquote><strong>4. Lock Fuse</strong>: Protects the microcontroller’s memory and fuse settings from being read or modified, ensuring secure operation.</blockquote><p>When you buy an Arduino Factory Default = 0 1 1 0 0 0 1 0 and Arduino Default = <strong>1 </strong>1 1 <strong>1 1 1</strong> 1 <strong>1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5fohO8vGRGVn4YeacWe6g.png" /></figure><p>We will start exploring these</p><h4>LFUSE = <strong>0</strong> 1 1 0 0 0 1 0</h4><p>Bit 7 = 0, which means is enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PQoUny48z2K8aj9V5p2_zQ.png" /></figure><ul><li>The default configuration (with the internal RC oscillator at 8.0 MHz and CKDIV8 fuse) ensures that the system clock is 1.0 MHz by default.</li><li>The startup time and time-out settings provide robustness, allowing the system to stabilize before starting.</li><li>These default settings are designed to be safe and reliable for all users, ensuring the microcontroller can be programmed using any available programming interface.</li></ul><h4>LFUSE = 0 1 1 0 0 0 1 0</h4><p>Bit 5 and 4 which helps in allocating the same clock for multiple microcontrollers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*75_C4xJ2XJwOjGmkx34AsA.png" /></figure><p>The combination of SUT1 and SUT0 bits selects the startup time for the clock source. This is particularly important when using crystal oscillators, ceramic resonators, or external clock sources that may require some time to stabilize.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mJhCFZai-2iVZVjed-VjMQ.png" /><figcaption>All possible combinations</figcaption></figure><h4>LFUSE = 0 1 1 0 0 0 1 0</h4><p>Bit 3, 2, 1, and 0. Clock source enable bits are used to enable or disable specific clock sources within a microcontroller. These bits are typically found in control registers associated with the microcontroller’s clock system. They allow the user to select which clock sources are active and which are not, based on the requirements of the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5arBPmdr2_NApC_OaiYE2w.png" /></figure><p>External or Internal oscillators can be selected. In the very first row, we have some called Low Power Crystal Oscillator. Which means the external oscillator.</p><p>Whereas the factory default comes with an internal crystal oscillator(8 Mhz): 0010.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2hhTT8X-fOl99L94Vy2JaA.png" /></figure><p>We want to change the <strong>Arduino Factory Default = 0 1 1 0 0 0 1 0 </strong>and to use 8MHz Clock as an internal oscillator <strong>LFUSE = 1 1 1 1 0 0 1 0 </strong>(Check 4th row in the above table)</p><p>1 1 1 1 0 0 1 0 = 0 x F2 (in hexadecimall)</p><p>Got your question! How to set the fuse now?</p><h3>AVRDude</h3><p>AVRDude (AVR Downloader/UploaDEr) is an open-source software tool used to program Atmel AVR microcontrollers. It supports a wide range of programming hardware devices, including Atmel’s own tools as well as various third-party programmers.</p><ul><li>Supports a variety of programming hardware, including STK500, AVRISP, USBasp, and more.</li><li>Programs AVR microcontrollers via serial, parallel, and USB connections.</li><li>Supports multiple firmware file formats, such as Intel Hex, Motorola S-record, and raw binary.</li><li>Can be used from the command line, making it flexible for automated build systems and scripts.</li><li>Offers extensive options for reading, writing, and verifying microcontroller memory, including flash, EEPROM, and<strong> fuse bits.</strong></li></ul><p>If you are looking for a one-liner?</p><p>It is a package that talks with the programmer. If you are wondering the full form of that — -&gt;</p><p>AVRDude stands for<strong><em> &quot;AVR Downloader/UploaDEr”</em></strong></p><p>Yes, AVRDude enables us to rewrite or reconfigure fuse bits on ATMEGA328 Us/Ps.</p><p>Before getting into the code we have to enable two checkboxes 1) Complie and 2) Upload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fc2MyoM4aYxoC-ivbwWaoA.png" /></figure><p>now Upload LED the code with the programmer!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cqDPWRPrRABo-IHK8qYuDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ls60OHnNWisGio3KHHducQ.png" /></figure><blockquote>“/Users/bhuvaneshwarikanagaraj/Library/Arduino15/packages/MiniCore/tools/avrdude/7.2-arduino.1/bin/avrdude” “-C/Users/bhuvaneshwarikanagaraj/Library/Arduino15/packages/MiniCore/hardware/avr/3.0.2/avrdude.conf” -v -V -patmega328 -cstk500v1 -P/dev/cu.usbmodem1201 -b19200 “-Ueeprom:w:/private/var/folders/sm/k0m75skx4qld92bzd3_64xnc0000gn/T/arduino/sketches/CFE07DBE7FE2173CDE3CDB344161E259/Blink.ino.eep:i” “-Uflash:w:/private/var/folders/sm/k0m75skx4qld92bzd3_64xnc0000gn/T/arduino/sketches/CFE07DBE7FE2173CDE3CDB344161E259/Blink.ino.hex:i”</blockquote><p>This is one thing we are concerned about.</p><p>Let&#39;s decode from scratch,</p><ol><li><strong>AVRDude Executable Path:</strong></li></ol><ul><li>&quot;/Users/bhuvaneshwarikanagaraj/Library/Arduino15/packages/MiniCore/tools/avrdude/7.2-arduino.1/bin/avrdude&quot;</li><li>Specifies the path to the AVRDude executable.</li></ul><p><strong>2. AVRDude Configuration File:</strong></p><ul><li>&quot;-C/Users/bhuvaneshwarikanagaraj/Library/Arduino15/packages/MiniCore/hardware/avr/3.0.2/avrdude.conf&quot;</li><li>Points to the AVRDude configuration file (avrdude.conf), which defines settings for different AVR microcontrollers.</li></ul><p><strong>3. AVRDude Options:</strong></p><ul><li>-v: Verbose output mode, providing detailed information during programming.</li><li>-V: Disable auto-verify after programming.</li><li>-p atmega328: Specifies the AVR microcontroller model (ATmega328 in this case).</li><li>-c stk500v1: Specifies the programmer type (STK500v1 protocol).</li></ul><p><strong>4. Serial Port Configuration:</strong></p><ul><li>-P /dev/cu.usbmodem1201: Specifies the serial port (/dev/cu.usbmodem1201) used to communicate with the microcontroller.</li><li>-b 19200: Specifies the baud rate (19200) for communication with the programmer.</li></ul><p><strong>5. Memory Operations:</strong></p><ul><li>&quot;-U eeprom:w:/private/var/folders/sm/k0m75skx4qld92bzd3_64xnc0000gn/T/arduino/sketches/CFE07DBE7FE2173CDE3CDB344161E259/Blink.ino.eep:i&quot;</li><li>Writes (-U eeprom:w) the EEPROM data (Blink.ino.eep) to the microcontroller.</li><li>&quot;-U flash:w:/private/var/folders/sm/k0m75skx4qld92bzd3_64xnc0000gn/T/arduino/sketches/CFE07DBE7FE2173CDE3CDB344161E259/Blink.ino.hex:i&quot;</li><li>Writes (-U flash:w) the flash (program memory) data (Blink.ino.hex) to the microcontroller.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M2DsrtmybFNu8BJTLYsSRQ.png" /></figure><p>Remember this <strong>0 x F2? We will hardcode this with </strong><em>m format.</em></p><p>Now let&#39;s navigate to AVRDude;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQg3cZgTI-do9QFtM-LbKw.png" /></figure><p>To change the low fuse (lfuse) bit of an AVR microcontroller using AVRDude, follow these steps:</p><pre> ./avrdude -C ../etc/avrdude.conf -p m328 -c stk500v1 <br>-P /dev/cu.usbmodem11201 -b 19200 <br>-U lfuse:w:0xF2:m</pre><p>If you are using 328p, please follow this command;</p><pre>./avrdude -C ../etc/avrdude.conf -p m328p <br>-c stk500v1 -P /dev/cu.usbmodem11201 -b 19200 <br>-U lfuse:w:0xF2:m</pre><p>Since I&#39;m using Arduino as a programmer I have stk500v1 if you any other you should change.</p><p>If you are boarded of uploading the code from Arduino use this;</p><pre>./avrdude -C ../etc/avrdude.conf -p m328 -c stk500v1 -P /dev/cu.usbmodem11201 <br>-b 19200 -U flash:w:/Users/bhuvaneshwarikanagaraj/Documents/Arduino<br>/Blink/build/MiniCore.avr.328.Blink.ino.hex</pre><p>Given the command you provided, here are the adjustments you need to make sure everything is correctly set up:</p><ol><li><strong>Microcontroller Type</strong>: Since you mentioned the chip is ATmega328 (not P), use -p m328.</li><li><strong>Serial Port</strong>: Use the correct serial port (/dev/cu.usbmodem11201).</li><li><strong>Configuration File</strong>: Ensure the path to the avrdude.conf file is correct.</li><li><strong>Hex File Path</strong>: Ensure the path to the hex file is correct and doesn’t break due to spaces or other characters.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*hRVI12_TovoHbUY1_GzJ_g.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YBMHJKJmS_fspYsBtMG4Hg.png" /><figcaption>Our Microcontroller uses an internal 8MHz Crystal Oscillator</figcaption></figure><p>Looking forward to catching up in the next blog!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0919cb4b729" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>