Build and flash klipper firmware for atmega328p (arduino nano) - NamkingWIN/3d_print GitHub Wiki

My plan is using Arduino nano to control the V0 simple display . Because I can not make the V0 simple display work well with my skr mini v1.1 also raspberry pi zero2 and 3b+. Its also show the screen well after booting but if the printer do some things, the display will cause the mcu (host from raspberry pi or skr mini) overload and klipper will be shutdown. I dont know whats happend and cant find out reason of this.

Thats why I want to use arduino nano to control this display.

Here are my steps to make the arduino work with klipper:

1. Update the bootloader for your arduino nano.

I use optiboot. You will need the usbasp device to flash bootloader for nano ( That I used same this)

Make sure you connect the arduino nano and uspasp over iscp pins on arduino nano right. This image below provide you all pins on arduino nano (include iscp pins)

Arduino nano pinout

Now, Flashing bootloader by follow this this and this or view on the summary on bellow:

All we need:

 1. AVRdude software (flash tool) --> [Link](http://download.savannah.gnu.org/releases/avrdude/)

 2. Zadig (install the usbasp driver) --> [Link](https://zadig.akeo.ie/downloads/)

First thing is install driver for usbasp: open Zadig application and following images below

Flashing time: open AVRdude application and follow at below

OK, now you have a arduino nano with new bootloader

2. Build firmware for atmega328p (arduino nano)

You can follow the guide from klipper website to build firware. I use 16Mhz for clock

Recently, the bullseye based distributions OS will cause the error when compiled the firmware that look like below:

 ...

 Linking out/klipper.elf 

 /usr/lib/gcc/avr/5.4.0/../../../avr/bin/ld: out/klipper.elf section  .data' will not fit in region `text' 

 /usr/lib/gcc/avr/5.4.0/../../../avr/bin/ld: address 0x800bc7 of out/klipper.elf section `.bss' is not within region `data' 

 /usr/lib/gcc/avr/5.4.0/../../../avr/bin/ld: address 0x800bc7 of out/klipper.elf section `.bss' is not within region `data' 

 /usr/lib/gcc/avr/5.4.0/../../../avr/bin/ld: region `text' overflowed by 1598 bytes 

collect2: error: ld returned 1 exit status 

Please fix by this guide

After that, you can compile the firmware successfully.

Next step, flash firmware to arduino nano: just do by this code

  make flash FLASH_DEVICE=/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0

Attention: change the id according to your board ( use "ls /dev/serial/by-id" to check).

Check the id of your board and implement to printer.cfg to import mcu(atmega328p) to your printer

You can use port pin mapped from arduino nano from the image upper to config your pin on cfg file.

Thats all and good luck!