Skewed screenshot of the compilation error in Marlin 2 firmware when using external I2C modules with 3d printer boards that use LPC176*, LPC1768 or LPC1769 chipsets.

I2C Error Marlin 2


I2C Compile Error in Marlin 2 with the LPC176X chipsets. Follow this guide to temporarily fix the issue with SKR V1.3, V1.4 and other printers.

As of firmware version 2.0.5 this issue as been resolved within Marlin Firmware. However I will leave the original post below for those not let upgraded to the latest Marlin version, or for similar issues that may arise in the future.

Moreover if you get an error similar to that shown below, try the fix in this guide to temporary solve the issue.

.pio/build/LPC1768/libFrameworkArduino.a(arduino.cpp.o): In function eeprom_write_byte(unsigned char, unsigned char)’: .platformio/packages/framework-arduino-lpc176x/cores/arduino/arduino.cpp:111: multiple definition of eeprom_write_byte(unsigned char, unsigned char)’

Screenshot of the compilation and build error in Marlin 2 firmware when using external I2C modules with 3d printer boards that use LPC176*, LPC1768 or LPC1769 chipsets.

In the file arduino.cpp (See path below) there is a section that is currently being duplicated in the HAL/shared/eeprom_i2c.cpp file. However we can’t remove the reference in the HAL version. Instead we need to get to the core of the Arduino framework.

platformio/packages/framework-arduino-lpc176x/cores/arduino/arduino.cpp

Without a doubt the problem is actually trying to find the file as it is deeply hidden.

Furthermore the full path for the file on a Mac is:

/Users/YourLoginName/.platformio/packages/framework-arduino-lpc176x/cores/arduino/arduino.cpp 

Additionally the full path for the file on a PC is:

C:\Users/YourUserName\.platformio\packages\framework-arduino-lpc176x\cores\arduino\arduino.cpp 

For PC users skip to the Editing on PC section.

Editing on Mac

screenshot of the Mac operating system Finder icon. Finder is used to navigate the Mac computers files.

On the Mac launch Finder then at the top of the screen in the Go section click on Computer.

screenshot of the Mac operating system shortcut for using Finder which is the left shift, C, and CMD buttons at the same time. Finder is used to navigate the Mac computers files.

  • Double click on Macintosh HD
  • Double click on Users
  • Double click on your login name

However at this point the folder we are after is hidden. So we need to unhide them.

At the same time press the CMD and the LEFT SHIFT BUTTON and the FULL STOP BUTTON. Furthermore this will reveal the hidden files and folders on your Mac. Additionally to hide the files again press the same keys as before.

While you will see a lot more folders suddenly reappear, the folder we are after is .platformio.

screenshot of the hidden .platformio folder used by PlatformIO to configure Marlin 2 firmware on a mac.

  • Double click on .platformio
  • Double click on packages
  • Double click on framework-arduino-lpc176x
  • Double click on cores
  • Double click on arduino

Furthermore scroll down and look for the file called arduino.cpp, right click on the file and select open with and then select TextEdit.

Editing the arduino.cpp on Mac

Once loaded scroll down until you find the Persistent Config Storage you cant miss it it looks like below.

screenshot of the arduino.cpp file used by PlatformIO and Marlin 2 3d printer firmware

// *********************
// Persistent Config Storage
// *********************

Without a doubt we need to disable this section. Use the below code as an example of what to disable by using double forward slashes // before each eeprom line (See below).

screenshot of the edited and fixed arduino.cpp file used by PlatformIO and Marlin 2 3d printer firmware. This fixes the I2C duplicate container build errors for Marlin 2 and LPC176*, LPC1768, and LPC1769 chipsets.

//
// Persistent Config Storage
//
// MAKE N PRINT SKR V1.4 I2C EEPROM FIX
// void eeprom_write_byte(uint8_t *pos, unsigned char value) { }
//uint8_t eeprom_read_byte(uint8_t * pos) { return ‘\0’; }
//void eeprom_read_block(void *__dst, const void *__src, size_t __n) { }
//void eeprom_update_block(const void *__src, void *__dst, size_t __n) { }
//

Now goto File and Save in Text Edit – Leave Text Edit open in case of a mistake.

Finally close Visual Studio Code and in-turn PlatformIO. Relaunch so that it can read the amended file. Before recompiling click on the clean option first, once completed the click build.

Furthermore the I2C Compile Error in Marlin 2 on the Mac should now be resolved.

While I have been using this method for a good few months I have not found an issues arising from its use.

If you found this guide useful, please consider a donation to help keep the Make ‘N’ Print website running. For further information please have a look at our support us page

Thank You

Editing on PC

screenshot of the Windows operating system File Explorer icon. File Explorer is used to navigate the Mac computers files.

On the PC launch file explorer.

screenshot of hard drive c: within Microsoft Windows File Explorer

Additionally scroll down on the left column and click on Local Disk for many this is C:

  • Double click on Local Disk (for many this is C:)
  • Double click on Users
  • Double click on your login name

However at this point the folder we are after is hidden. So we need to unhide them.

screenshot of Microsoft Windows Control Panel when searched via the search feature

Goto to the search Web and Windows search bar type Control Panel.

screenshot of the Microsoft Windows configuration Appearance and Personalization to unhide hidden files

Click on the Control Panel Icon
Click on Appearance and Personalisation

screenshot of Microsoft Windows File Explorer Options quick link to Show Hidden files and folders

Furthermore on the File Explorer Options click on Show hidden files and folders.

screenshot of Microsoft Windows File Explorer Options with the Show Hidden Files, folders, and drives option ticked and enabled

Additionally a new options window will open, look for and tick the option for show hidden files, folders, and drives. Then Click on Apply towards the bottom right of the option window.

screenshot fo .platformio hidden folder on a Microsoft Windows PC with File Explorer

Finally return to File Explorer and you should now see the .platformio folder.

  • Double click on .platformio
  • Double click on packages
  • Double click on framework-arduino-lpc176x
  • Double click on cores
  • Double click on arduino
screenshot of Microsoft Windows, how to you want to open this file menu.

Furthermore look for the file called arduino.cpp, right click on the file and select the open with and option. Next select search through Windows, when icons appear click on Word Pad and click OK.

Editing the arduino.cpp on PC

Once loaded scroll down until you find the Persistent Config Storage you cant miss it it looks like below.

screenshot of notepad on Microsoft Windows PC editing the arduino.cpp file for PlatformIO and Marlin 2 Firmware to fix the duplicate I2C EEPROM build and compilation error

// *********************
// Persistent Config Storage
// *********************

Without a doubt we need to disable this section. Use the below code as an example of what to disable by using double forward slashes // before each eeprom line (See below).

screenshot of notepad on Microsoft Windows PC with the edited arduino.cpp file for PlatformIO and Marlin 2 Firmware to fix the duplicate I2C EEPROM build and compilation error

//
// Persistent Config Storage
//
// MAKE N PRINT SKR V1.4 I2C EEPROM FIX
// void eeprom_write_byte(uint8_t *pos, unsigned char value) { }
//uint8_t eeprom_read_byte(uint8_t * pos) { return ‘\0’; }
//void eeprom_read_block(void *__dst, const void *__src, size_t __n) { }
//void eeprom_update_block(const void *__src, void *__dst, size_t __n) { }
//

Now goto File and Save in Word Pad – Leave Word Padt open in case of a mistake.

Finally close Visual Studio Code and in-turn PlatformIO. Relaunch so that it can read the amended file. Before recompiling click on the clean option first, once completed the click build.

Furthermore the I2C Compile Error in Marlin 2 on the PC should now be resolved.

If you found this guide useful, please consider a donation to help keep the Make ‘N’ Print website running. For further information please have a look at our support us page

Thank You


© 2019-2020 Copyright - All Rights Reserved.