Tuesday, May 6, 2025

Hello World on Ubantu Docker Image

 Steps to run simple C program on Ubantu Docker image:

1. Following files needs to be created in Working Directory folder.

   hello.c

   Dockerfile

2. hello.c file contains c program with Hello, World! message printed out.

3. Dockerfile should contain below code

         FROM ubuntu:latest

         RUN apt-get update && apt-get install -y gcc

         COPY hello.c /app/hello.c

         WORKDIR /app

         RUN gcc -o hello hello.c

         CMD ["./hello"]

4. Build docker image using command " docker build -t my-hello-app ."

5. Once docker image is built, run the docker container using command "docker run my-hello-app"

6. Hello, World! will be printed out.

Monday, May 5, 2025

Run GCC Docker image on Raspberry pi

 Steps to Run GCC Docker image on Raspberry pi:

1. Create folder with below contents:

    build --> Folder
    Dockerfile --> Docker image file
    main.c  --> C Program

2. Write a simple c program into main.c file
     // C program to implement
    // the above approach
    #include <stdio.h>

    // Driver code
    int main()
    {
        printf("Welcome to Docker World!!!\n");
        return 0;
    }

3. Edit Dockerfile and write below contents
    FROM gcc:latest
    COPY . /build
    WORKDIR /build/
    RUN gcc -o main main.c
    CMD [“./main”]

4. Save and Build Dockerfile, using command "docker build -t main-gcc-app ."
    DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
                Install the buildx component to build images with BuildKit:
                https://docs.docker.com/go/buildx/

    Sending build context to Docker daemon  488.4kB
    Step 1/5 : FROM gcc:latest
    latest: Pulling from library/gcc
    de07ba6f486e: Pull complete 
    84649bff67ea: Pull complete 
    48a2a14f59a0: Pull complete 
    0d41c7623f41: Pull complete 
    e532a4816a8d: Pull complete 
    d758cb5cc483: Pull complete 
    1a9014bafd27: Pull complete 
    d7ff42aa73d4: Pull complete 
    Digest: sha256:16aea78a24ad0c562e63fe3060d3ce85f96101ecd1db09b67b1ccd9bff7dfe4d
    Status: Downloaded newer image for gcc:latest
     ---> 74afbe6d78a1
    Step 2/5 : COPY . /build
     ---> 5c8449b50bb9
    Step 3/5 : WORKDIR /build/
     ---> Running in 821db3d73da8
     ---> Removed intermediate container 821db3d73da8
     ---> b6fb3ea1b178
    Step 4/5 : RUN gcc -o main main.c
     ---> Running in 5033bc4e8723
     ---> Removed intermediate container 5033bc4e8723
     ---> e686a8e707a2
    Step 5/5 : CMD [“./main”]
     ---> Running in e51cd5d36d82
     ---> Removed intermediate container e51cd5d36d82
     ---> aa4223676951
    Successfully built aa4223676951
    Successfully tagged main-gcc-app:latest

5. Check is docker image is built "docker image ls"

6. Run docker image "docker run -it main-gcc-app" Hello world will be displayed.

Install and Run Docker on Raspberry Pi

Steps to Install and Run Docker Image on Raspberry Pi board:

1. Connect Raspberry Pi from VSC via SSH connection

2. Run Command "sudo apt install docker.io"

3. Check if docker is installed properly by checking version "docker --version"


4. Pull simple docker hello-world image, by running command "docker run hello-world"

5. If permission access is shown then run below commands to add user.
    sudo usermod -a -G docker $USER
    grep docker /etc/group
    newgrp docker

6. Hello world message will be shown after running Docker image


7. All created images can be seen by running command "docker image ls"

8. From available docker image list, we can run the image whichever we want 

example. docker run hello-world:latest

Sunday, May 4, 2025

Connecting VSC with Raspberry Pi via SSH

 Steps to connect VSC to Raspberry Pi Running on Linux with SSH.

1. Follow steps mentioned in Putty blog to Enable SSH on Raspberry Pi.

2. Enable Extension " Remote - SSH" in VSC.

3. Go to view>Command Palette>Remote-SSH: Add new SSH host.

4. Enter ssh <username>@<Ip address>

5. Select config file with your user name. This will start setting up SSH Host.

6. It will prompt to enter password for your Raspberry Pi device.

7. After entering valid password SSH is established.


8. Now you can open folder from Raspberry Pi device. Which is your working Directory. 

Saturday, May 3, 2025

Connecting Raspberry Pi via Putty

 Steps to connect your Raspberry pi (Running with Linux) to Putty (Running on Windows 11):

1. Install ssh on Raspberry Pi Linux using command

    sudo apt install openssh-server

2. Enable Ssh Service

    sudo service ssh start

3. Make it always Enabled on Bootup

   sudo systemctl enable ssh

4. Read Ip address of Raspberry Pi

5. Open Putty Tool on Windows Machine, Enter Ip address and connect



6. It will open Window like shown below, Login with credentials and password.


7. You are ready to control Raspberry Pi Linux with Putty tool. 

Sunday, February 18, 2024

Reading current date and time using RTC on STM32F407VET6

In STM32F407VET6 board we can calculate current date and time using following steps:

1. Go to Pinout & Configuration> Timers> RTC in RTC mode and Configuration.

2. Activate Clock Source & Activate Calendar should be enabled.

3. Alarm A should be selected as Internal Alarm.

4. Go to parameter configuration of RTC, set date and time to marked configuration below:


5. Enable interrupt in NVIC Settings


6. To read the date and time following code needs to be called in main.c file.

  RTC_TimeTypeDef sTime1;

  RTC_DateTypeDef sDate1;


  uint8_t buffer[20];


/* USER CODE BEGIN WHILE */


while (1)

{

        HAL_RTC_GetTime(&hrtc, &sTime1, RTC_FORMAT_BCD);

HAL_RTC_GetDate(&hrtc, &sDate1, RTC_FORMAT_BCD);


buffer[0] = (sDate1.Date / 16) + 48;

buffer[1] = (sDate1.Date % 16) + 48;

buffer[2] = '.';

buffer[3] = (sDate1.Month / 16) + 48;

buffer[4] = (sDate1.Month % 16) + 48;

buffer[5] = '.';

buffer[6] = '2';

buffer[7] = '0';

buffer[8] = (sDate1.Year / 16) + 48;

buffer[9] = (sDate1.Year % 16) + 48;

buffer[10] ='@';

buffer[11] = (sTime1.Hours / 16) + 48;

buffer[12] = (sTime1.Hours % 16) + 48;

buffer[13] = ':';

buffer[14] = (sTime1.Minutes / 16) + 48;

buffer[15] = (sTime1.Minutes % 16) + 48;

buffer[16] = ':';

buffer[17] = (sTime1.Seconds / 16) + 48;

buffer[18] = (sTime1.Seconds % 16) + 48;


}

/* USER CODE END 3 */


6. After building and flashing the code we will see result as shown below:

Decoded as 18.02.2024@20:20:46

Monday, February 12, 2024

CRC calculation in STM32F407VET6

 In STM32F407VET6 board we can calculate CRC-32/MPEG-2 using following steps:

1. Enable CRC engine at Pinout & Configuration> Computing> CRC mode and Configuration should be activated

2. Save project and generate the project

3. Define data buffer on which we wants to calculate CRC

uint32_t crcArray[4] = {0x00001111, 0x00002222, 0x00003333, 0x00004444};

4. Function call for crc needs to be called in main function as:

crcVal = HAL_CRC_Calculate(&hcrc, crcArray, 4);

Where, uint32 of CRC will be returned.

5. After running the code we will get CRC as shown below:


6. Verify CRC using Online calculator 



CRC value calculated on STM32 and online calculator are matching.

Hello World on Ubantu Docker Image

 Steps to run simple C program on Ubantu Docker image: 1. Following files needs to be created in Working Directory folder.    hello.c    Doc...