-
-
Notifications
You must be signed in to change notification settings - Fork 183
Developer Information
##How to compile the bootloader
You can compile the bootloader with a Raspberry Pi, Ubuntu or Windows yourself. Everything you need is covered here (avr-gcc 4.7.2, 4.8.1 and 4.9.2 as well!). See this tutorial on how to get the newer 4.8.1 for raspberry pi and this tutorial to get the newest 4.9.2 for Windows.
HoodLoader2.0.3 compiles with 3958(+2 for Mega) bytes with avr-gcc 4.7.2 and with 3908(+2 for Mega) bytes with avr-gcc 4.8.1.
####How to use AVR-GCC 5.1 with LTO (required for 2.0.5) Download from here: https://github.com/arduino/Arduino/issues/660#issuecomment-120433193
Add the compiler temporary to your PATH variable before you compile.
PATH=~/bin/pkg-x86_64-unknown-linux-gnu/bin:$PATH
Add -flto -fuse-linker-plugin
to your CC_FLAGS and LD_FLAGS.
##USB PID/VID
The HoodLoader2 itself uses the official Arduinos VID and PID. The HID Project and the board definition files uses a special PID but this has nothing to do with the bootloader itself. See current inf file/boards.txt for more used PIDs
#define LUFA_VID 0x03EB
#define LUFA_PID 0x204A
#define ARDUINO_VID 0x2341
#define ARDUINO_UNO_PID 0x0043 // R3 (0001 R1)
#define ARDUINO_MEGA_PID 0x0042 // R3 (0010 R1)
#define ARDUINO_MEGA_ADK_PID 0x0044 // R3 (003F R1)
HoodLoader2atmega16u2.vid.0=0x2341
HoodLoader2atmega16u2.pid.0=0x484C
HoodLoader2atmega32u2.pid.0=0x484D
HoodLoader2atmega8u2.pid.0=0x484E
HoodLoader2at90usb162.pid.0=0x484F
##Changes to the Atmega Bootloader Programmer
To upload the HoodLoader2 I used a modification of Nick Gammon's Atmega Bootloader Programmer. Instructions can be found here.
One of the change was to add new bootloader files. You can convert your hex file as described with Nick's Lua script. One thing to add is the address of the 16u2 in the end_addresses array (line 16). The new .lua script is also in the repository now.
You need to download the MUSHclient as described in his instructions. He provides a simple, ready to use zip file.
##Compiling with avr-gcc 4.9.2 under Windows Extracted from the old Wordpress blog.
Yeah you heard right! The newest, hottest and sexiest avr-gcc is now available, for windows! This tutorial also works for older versions like 4.7.2 or 4.8.1 though. I still have no idea how to use 4.9.2 with linux, but at least 4.8.1 is working.
- The process is fairly simple. Download the "latest" WinAVR release and install it (it's very old).
- As described in the german tutorial download the lastest WinAVR compile patch from here.
- Backup the old release
- Copy and replace all new files into the WinAVR installation path.
- Check the version with an administrative cmd: avr-gcc -v
- Patch the WinAVR release with this solution if its not working.
- Compile your stuff. Try something like my HoodLoader2 bootloader.
- Thats it.
Optionally you can also try the official atmel toolchain as described here. Make sure that you remove WinAVR from your systems PATH variable then. You can access it via computer, properties, advanced settings, environment variables and add an entry at the bottom called "PATH" and add the paths listed there. At the date of writing this post, the atmel toolchain for windows "only" supports avr-gcc 4.8.1
##How to (cross-)compile AVR programs with Raspberry Pi Extracted from the old Wordpress blog.
Compiling AVR programs with Windows is very tricky. Compiling makefiles with Linux environments is a lot easier. You want to compile AVR programs (like LUFA programs) with a Linux system but still want to stick to your Windows editors? Don't want to install Ubuntu on a 2nd PC/VM and you also got a Raspberry Pi lying around which might not be in use? Perfect! This tutorial covers how to install the avr-gcc tools and how to exchange the code with your Windows PC. Optionally there are also notes for Ubuntu as well (works nearly the same).
For compiling avr programs we need a compiler of course. It's called avr-gcc (but the package is called gcc-avr). Currently there are two mainly available versions of the compiler: 4.7.2 and 4.8.1 The newer version compiles code with better optimization which might be important for bootloaders which have to fit into a specific size of flash. Since 4.8.1 is not in the current stable repositories you have to do some extra steps in order to install 4.8.1 for raspberry pi. For Ubuntu just use the first line in the instructions to get 4.8.1 instead of 4.7.2. If you are a lazy guy you can start with 4.7.2 and update the packages later again. [code language="bash"] # Ubuntu and 4.8.1 only! Add new avr-gcc 4.8.1 package sudo add-apt-repository ppa:pmjdebruijn/gcc-avr-release # reload repositories and check for the gcc-avr package sudo apt-get update sudo apt-cache search gcc-avr # install avr-gcc 4.7.2 sudo apt-get install gcc-avr avr-libc # check installed version of avr-gcc avr-gcc -v [/code]
Now we need to check if the compiling in general works. In this example I simply download one of my projects: HoodLoader2. You will notice that the flash size shrinks with the newer 4.8.1 version. [code language="bash"] # download a project of your choice wget https://github.com/NicoHood/HoodLoader2/archive/master.zip unzip -g master.zip cd HoodLoader2-master sudo make [/code]
As said at the beginning, you can use the Raspberry Pi as cross-compiler. This might sound stupid, since it has not the fastest processor but its a fairly simple solution if you want to code with Windows. For Laptop users it might be useful to connect your Raspberry directly to your PC instead of using WLAN on both devices. See this tutorial. It is also highly recommended to use Putty for an SSH connection so you don't need a display on your Raspberry Pi. So first we have to create a Windows share on your Windows PC. Right click the folder you want to share (in my case named 'Arduino') and click on properties->sharing->Advanced Sharing. Select 'Share this folder' and also click on 'permissions' and check all boxes under 'allow'. We have to do this so the Raspberry is allowed to save the new files. Keep in mind that its also allowed to delete files in this share. Make sure to backup the files in the share. Now we have to mount this share with your Raspberry Pi. You can temporary mount the share or on each startup. In any case I recommend you to first test the mounting, then add it to the startup. To find your PC name right click Computer (or this PC) and click on properties. The name should be listed there. You have to enter the letters in upper case for the mount. [code language="bash"] # create the folder where its mounted in cd Desktop mkdir Arduino #Test mounting: sudo mount -t cifs -o username=yourusername,password=yourpass,nounix,noserverino //YOUR-PC-NAME/Arduino Arduino cd Arduino ls # run it automated at startup. If not connected this can cause a long timeout. sudo nano /etc/fstab //YOUR-PC-NAME/Arduino /home/pi/Desktop/Arduino cifs username=yourusername,password=yourpass,nounix,noserverino 0 0 # reboot the raspi and check if it works sudo reboot [/code] You are now able to edit the files with your editor of choice under Windows (for me it's Visual Studio) and compile it with a Raspberry Pi over Ethernet.
- https://nicohood.wordpress.com/2015/01/24/installing-avr-gcc-4-8-1-and-arduino-ide-1-6-on-raspberry-pi/
- https://launchpad.net/~pmjdebruijn/+archive/ubuntu/gcc-avr-release
- http://www.fourwalledcubicle.com/LUFA.php
- https://launchpad.net/~pmjdebruijn/+archive/ubuntu/gcc-avr-release
- http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Copyright (c) 2014-2021 NicoHood
Additional Information